only allowing one connection per IP address

Frederic Bregier fredbregier at free.fr
Wed Mar 18 05:31:59 EDT 2009


Hi William,

I would say that you probably have to handle this in the channelConnected
(or channelOpen or channelBound) method of your ChannelHandler. 
For instance, you can create a HashMap storing
all currently connected IP addressed used by the clients to connect to
the server (channel gives you the address through getRemoteAddress method).
Then, when the connection is on going, you can check first if this address
is currently used.
If not, you let it continue and add this address to the hashmap. 
If yes, then you immediately close the channel.
Of course, don't forget on channelClosed method to remove the corresponding
address from the hashmap.

HTH,
Frederic

-----
Hardware/Software Architect
-- 
View this message in context: http://n2.nabble.com/only-allowing-one-connection-per-IP-address-tp2495797p2496141.html
Sent from the Netty User Group mailing list archive at Nabble.com.




More information about the netty-users mailing list