Socket Bind Error

Posted by rantravee on Stack Overflow See other posts from Stack Overflow or by rantravee
Published on 2009-07-06T06:30:32Z Indexed on 2010/04/16 14:33 UTC
Read the original article Hit count: 381

Filed under:
|

Hi,

I have a test application that opens a socket , sends something through this socket and then closes it . This is done in a loop for 5-10.000 times. The thing is that after 3,4000 iterations I get an error of this type :

enter code here
java.net.BindException: Address already in use: connect

I even set the socket to be used immediattly, but the error persists

enter code here
try
{
     out_server.write(m.ToByteArray());
     socket_server.setReuseAddress(true);
     socket_server.close();
}
catch(Exception e)
{
     e.printStackTrace();
     System.out.println(i+" unable to register with the server");
}

What could I do to fix this ?

© Stack Overflow or respective owner

Related posts about java

Related posts about sockets