Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Scoket connect fails with: Can't assign requested address

807605Sep 7 2007 — edited Sep 8 2007
Hi All,

I am running Java on Mac OS X 10.4.8 (Intel). I run the following code:

for (i=0; i<20000; i++) {
java.net.Socket socket = new java.net.Socket();

socket.connect(new java.net.InetSocketAddress("localhost", 80));
socket.close();
}

After about 16380 local TCP connections, connect is failing with the error message "Can't assign requested address".

After waiting for a while, I can connect again.

It looks like Java is consuming all client-side TCP ports. When the error occurs, I also start to have problems connecting from my browser to any Web-page.

Am I having to wait for the garbage collector to free the ports, or is this an OS X problem?

Any help or ideas would be welcome.

Thanks,

Paul
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 6 2007
Added on Sep 7 2007
3 comments
431 views