Reputation: 67
I am having some problems setting up a session management system for UDP with the Netty framework. I am confused about what is new per UDP remote client. For every new UDP remote client, does that client get a new ChannelPipelineFactory, or is a new Channel created per new remote client?
I have 2 ports, port 161 and port 162 that are both UDP ports and both will be receiving data from numerous UDP clients. How can I differentiate between the clients? I started to create a session management service based on RemoteAddress
provided by DatagramPacket.sender()
but I don't know if it's safe to attach to the ChannelHandlerContext
attribute() chain.
Upvotes: 1
Views: 1463
Reputation: 9051
Since UDP is connection less, the DatagramPacket.sender
will be your only option to route messages to the appropriate session. There is conceptually only one ChannelPipelineFactory
and in fact only one Channel
for UDP for the application. As far as I know it is not safe to attach the ChannelHandlerContext
. The way to deal with multiple clients is to use a Map
with the key as the DatagramPacket.sender
address and value as your session
.
Upvotes: 2