Scoket connect fails with: Can't assign requested address
807605Sep 7 2007 — edited Sep 8 2007Hi 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