Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between channel.isOpen() and channel.isConnected() in Netty?

Tags:

java

netty

Netty defines two methods for channels: isOpen() and isConnected(), but the Javadoc does not really explain the difference between both and it is not self-explanatory. Can anyone clarify?

Is the following true?

-) An open channel is always connected

-) A connected channel does not mean one can use it to communicate, it must be open too

-) UDP-like channels are never connected

Thanks.

like image 542
Jérôme Verstrynge Avatar asked Apr 19 '11 10:04

Jérôme Verstrynge


People also ask

What is a channel in Netty?

Netty Channel Channel is a component providing users a ways to process I/O operations, such as read and write. A ChannelPipeline encapsulates a series of ChannelHandler instances as two-way linked list. Inbound and outbound events that flow through a channel can be intercepted by the ChannelPipeline.


1 Answers

That's incorrect, a channel can be open and not connected, but a connected channel is necessarily open.

You can send data to an open channel that is not connected for connectionless transports using the write method that takes a SocketAddress as a parameter. Otherwise the channel needs to already be open and connected.

like image 140
Mat Avatar answered Oct 13 '22 22:10

Mat