DatagramSocket vs DatagramChannel behavior in disconnect()

Alan Bateman Alan.Bateman at oracle.com
Fri Feb 28 07:28:42 PST 2014


On 28/02/2014 14:59, Florian Weimer wrote:
> 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?
>
Does the ChangingAddress test fail for you? I thought it was just that 
the local address might change (after connect or disconnect) and not 
that the socket would move an unbound state.

-Alan


More information about the nio-dev mailing list