Allowing only a single persistent connection

Bob Bucy bob.bucy at gmail.com
Tue Apr 21 18:56:15 EDT 2009


I'm looking at how to implement a service that allows only a single server
connection.  In other words, upon accepting a connection, I would like to
close the listener channel (e.g. NioServerSocketChannel); thus, any new
attempts to connect to my service would immediately be rejected.  

Upon losing the connection with the accepted socket channel (e.g.
NioAcceptedSocketChannel), I then would want to start listening for
connections again.

Right now, I am calling the NIOServerSocketChannel.close() method in my
handlers channelConnected method, and calling ServerBootstrap.bind()
connection in my handler's channelDisconnected() method.  This seems to
work, thinking the close() totally shuts down the Boss thread, and the
bind() starts it back up.

Does this make sense or am I heading towards disaster.

--bob
-- 
View this message in context: http://n2.nabble.com/Allowing-only-a-single-persistent-connection-tp2672989p2672989.html
Sent from the Netty User Group mailing list archive at Nabble.com.




More information about the netty-users mailing list