0

Even though I call ServerSocket.setReuseAddress(true), I still get java.net.BindException: Address already in use on some machines if the port has been recently used.

InetSocketAddress isa = new InetSocketAddress(13025);
ServerSocket serverSocket = new ServerSocket();         
serverSocket.setReuseAddress(true);
serverSocket.bind(isa, 50);

My understanding from the documentation is that the reuse flag will ensure that the port can be bound to, even though the port may be in a TIME_WAIT state.

Is there some way around this? Is there a kernel setting for this, since it only happens on some (older and probably slower) machines.

John Farrelly
  • 7,289
  • 9
  • 42
  • 52

0 Answers0