setTransports( transport );
DatagramAcceptor acceptor = (DatagramAcceptor)transport.getAcceptor();
// Set the handler
acceptor.setHandler( new ChangePasswordProtocolHandler( this, store ) );
// Allow the port to be reused even if the socket is in TIME_WAIT state
((DatagramSessionConfig)acceptor.getSessionConfig()).setReuseAddress( true );
// Start the listener
acceptor.bind();
}
else
{
for ( Transport transport:transports )
{
IoAcceptor acceptor = transport.getAcceptor();
// Disable the disconnection of the clients on unbind
acceptor.setCloseOnDeactivation( false );
if ( transport instanceof UdpTransport )
{
// Allow the port to be reused even if the socket is in TIME_WAIT state
((DatagramSessionConfig)acceptor.getSessionConfig()).setReuseAddress( true );
}
else
{
// Allow the port to be reused even if the socket is in TIME_WAIT state
((SocketAcceptor)acceptor).setReuseAddress( true );
// No Nagle's algorithm
((SocketAcceptor)acceptor).getSessionConfig().setTcpNoDelay( true );
}
// Set the handler
acceptor.setHandler( new ChangePasswordProtocolHandler( this, store ) );
// Bind
acceptor.bind();
}
}