Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding channelRegistered in netty 4, when could a channel be re-registered?

As introduced in Netty New and noteworthy in 4.0:

channelOpen, channelBound, and channelConnected have been merged to channelActive. channelDisconnected, channelUnbound, and channelClosed have been merged to channelInactive. Likewise, Channel.isBound() and isConnected() have been merged to isActive().

Note that channelRegistered and channelUnregistered are not equivalent to channelOpen and channelClosed. They are new states introduced to support dynamic registration, deregistration, and re-registration of a Channel, as illustrated below: enter image description here

IMHO, in scenario of TCP/IP, when a channel is unregistered, the corresponding socket is closed, how could it be re-register again?

like image 582
Weibo Li Avatar asked Sep 26 '22 04:09

Weibo Li


1 Answers

When you deregister a Channel it basically removed itself from the servicing Thread which in the case of NIO also is the Selector itself. This means you will not get notified on any event changes. Once you register again the Channel will be registered on a Selector again and you will get noticed about events (like OP_READ, OP_WRITE etc).

like image 56
Norman Maurer Avatar answered Sep 29 '22 05:09

Norman Maurer