DatagramSocket vs DatagramChannel behavior in disconnect()
Florian Weimer
fweimer at redhat.com
Fri Feb 28 06:59:50 PST 2014
Sockets preserve the local address on disconnect(), but channels don't.
Bug 6431343 reflects that, but this is still surprising and violates
the NetworkChannel contract ("Once an association is established then
the socket remains bound until the channel is closed").
I see this on Linux. Behavior on other systems is different. For
datagram sockets, the native disconnect() implementation has a
Linux-specific workaround for this, but DatagramChannel lacks it.
What's the best way to address this? Adjust the NetworkChannel
documentation? Apply the DatagramSocket workaround to DatagramChannel
as well?
--
Florian Weimer / Red Hat Product Security Team
More information about the nio-dev
mailing list