开发者

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

开发者 https://www.devze.com 2023-02-27 04:15 出处:网络
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. Ca开发者_StackOverflow社区n anyo

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. Ca开发者_StackOverflow社区n 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消