only allowing one connection per IP address

Frederic Bregier fredbregier at free.fr
Thu Mar 19 03:04:45 EDT 2009


Hi William,

As far as I know, no, I don't think Netty as a list of current active
connections.
Except if you consider ChannelGroup (which is good to have in order to make
easier the shutdown), but you have to handle it (adding/removing channels
from channelConnected/channelClosed methods).
You can then use this channelGroup to find if there is already one channel
that use the same address than the one currently in the process of
connection.
ChannelGroup implements the Set feature, sot it could be less efficient than
a hashmap since you will have to iterate on each object inside the group
(set)
in order to be sure that the address is not found.

Your need is quite specific and I feel like it should be handled with a
specific
way. You can also implement a simple handler in your pipeline that just do
that
(check in a hashmap the existence of a previous and running channel with the
same
base address -not the port, only the ip address-). For me, it seems the best
way. 

Perhaps we can include in Netty such a handler (to be included in a
pipeline) that will allow/disallow on such conditions the connections.
However, we need then to find what kind of options could be let to the
programmer
on what could be the conditions.

Also, the point is that the connection opens first before the check can
occur.
So in a scenario where the connection would not be allowed, the scheme would
be
first connection, then test then immediate disconnection.
Sometime I feel like it would be nice to be able in general protocols to
send a message that would basicaly says "connection refused".

If you have any idea on what could be such a handler and what could be its
facilities and options, we can try to implement such a default handler
in Netty... ? WDYT ?

HTH,
Frederic

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




More information about the netty-users mailing list