Simple question, simple solution:
unlike ServerSocketChannels NioSocketAcceptors default to
"reuse address", meaning that...
acceptor.setReuseAddress(false);
... will solve the mentioned problem.
Rgds, Alex
Hi,
I did a really simple server for testing purposes.
I figured out that I can start two of them on the same port and
wondering why I'm not getting the typical "java.net.BindException:
Address already in use" or the like?!
Both servers pretend to be "active" but only one really is.
And when I stop the "winner" the sencond one takes over...
So, how can I get back my BindException?
Is this an NIO problem?
Thanks! Best Regards, Alex ;)
public class SimpleServer {
private static final int PORT = 6597;
public static void main(String[] args) throws IOException {
final SocketAcceptor acceptor = new NioSocketAcceptor();
acceptor.setHandler(new IoHandlerAdapter());
acceptor.bind(new InetSocketAddress(PORT));
System.err.println(acceptor.isActive());
}
}