Channel open event for UDP and TCP on bind

fps fred.soulier.ml at gmail.com
Wed Jan 6 09:01:06 EST 2010



Trustin Lee wrote:
> 
> It is an expected behavior.
> 
> In a TCP server, a channel is open only when a client connects to it.
> To be more precise, a server socket gets the initial channelOpen event
> on bind, but it is hidden by ServerBootstrap.  What you deal with in
> your handler is the channel accepted by the server socket.
> 
> In a UDP server, a channel is open immediately on bind and you can
> receive and send the UDP packets without accepting anything because
> there is no notion of connection in UDP.
> 
> Simply, think about writing a TCP or UDP server by yourself.  When you
> write a TCP server, you accept a new socket from a server socket and
> then use the accepted socket to communicate with the client.  When you
> write a UDP server, you simply create a socket bound to a port and then
> keep using it to communicate.
> 

Thx Trustin for your quick reply, as always :)

At least I know I'm not imagining things which is good ;)
Having said that I understand the difference between the non-connected
nature of UDP and the connected nature of TCP but the difference in
behaviour of bind(..) rattles me somewhat :)

For TCP the server will trigger a channel open event upon connecting a
client which is fine then whatever the client decides to send is received.
For UDP when a client sends the first message wouldn't it make sense at that
point to trigger first a channel open followed by receiving the message?

This way the bind(...) behaviour is consistent and the channel open event
for UDP (triggered at the same time as the first message is received) would
allow to get the remote address from the channel (in the channelOpen(...)
method as per TCP) which is not the case with the current behaviour.

I may be overlooking some other aspects of the architecture of Netty so
please excuse me if the above doesn't make sense.

Frederic
-- 
View this message in context: http://n2.nabble.com/Channel-open-event-for-UDP-and-TCP-on-bind-tp4260514p4260763.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list