hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "bagas" <ba...@indoartha.co.id>
Subject RE: [newbie-question] Port Management for HttpClient
Date Fri, 11 Jun 2004 07:03:25 GMT
I am changing HttpConnection.open()

Bye changing code line :
 
socket = socketFactory.createSocket(host, port);

become like : (portIter is a class field type int)

socket = socketFactory.createSocket(host, port,
InetAddress.getByName("localhost"), 20000 + (portIter++ % 10000));

and it works "much better" that the standard Implementation (yes I
assume between port 20000 - 30000 just a little are used). FYI, I
analyze from my codes with standard HttpConnection.open()implementation
the port allocation just circling around port 3000 to 4000

What I want to ask you are how can make this kind of arrangement in
HttpClient in "best" fashion? I think I would be able to make "much
better" solution by using HttpClient.setHttpConnectionManager() (and
somehow make it allocate port between 20000 - 30000)  right? But anyway
I still waiting for a better solution that I could use.

Thank you,

Rahmat Bagas Santoso.	



-----Original Message-----
From: bagas [mailto:bagas@indoartha.co.id] 
Sent: Friday, June 11, 2004 11:12 AM
To: 'Commons HttpClient Project'
Subject: RE: [newbie-question] Port Management for HttpClient

What Platform are you on?
Windows XP (but I might change the platform for the real deployment)

And this is the JVM :

java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)


Can you provide a full stack trace please? OK
------------------------------------------------------------------------
---java.net.BindException: Address already in use: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
        at
java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
        at java.net.Socket.connect(Socket.java:426)
        at java.net.Socket.connect(Socket.java:376)
        at java.net.Socket.<init>(Socket.java:291)
        at java.net.Socket.<init>(Socket.java:119)
        at
org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.crea
teSocket(DefaultProtocolSocketFactory.java:118)
        at
org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:68
3)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:6
62)
        at
org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:5
29)
        at gateway.Main$5.run(Main.java:263)
------------------------------------------------------------------------
---

I think if I can allocate the Socket port for HttpClient connection
according to my rule, I will resolve this trouble. Could you tell me how
can I do this?


Thank you very much.

Regards,

Rahmat Bagas Santoso

-----Original Message-----
From: Ortwin Glück [mailto:ortwin.glueck@nose.ch] 
Sent: Thursday, June 10, 2004 6:24 PM
To: Commons HttpClient Project
Subject: Re: [newbie-question] Port Management for HttpClient



bagas wrote:
>  I think using 20 thread
> in the same time means I only use 20 ports (and another 20 ports use
by
> the Webserver) at the same time and there is still a lot of ports in
my
> computer that HttpClient can bind but still HttpClient often throws
> exception because trying to bind already bound Socket. 


Thanks

Ortwin Glück

---------------------------------------------------------------------
To unsubscribe, e-mail:
commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail:
commons-httpclient-dev-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail:
commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail:
commons-httpclient-dev-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-httpclient-dev-help@jakarta.apache.org


Mime
View raw message