OK Alan, Daniel thanks for the feedback and consideration … but what you say does lend an argument that localAddress = null; rather than localAddress = isa; is a reasonable value in the event of Net.bind throwing a BindException 😮
but, as you have said, that may have other implications leaving my dead donkey well and truly flogged!! an influencing (rhetorical) question is how soon is a port available for re-allocation/re-use after it has been released by the OS on Linux? with connected TCP sockets it would expected to be the TTL setting … not sure about a connected UDP socket! Would it be instantaneously available after its release by the kernel, or subject to TTL lifetime? best regards Mark ________________________________ From: Daniel Fuchs <daniel.fu...@oracle.com> Sent: Tuesday 8 October 2019 14:40 To: Alan Bateman <alan.bate...@oracle.com>; mark sheppard <macanao...@hotmail.com>; nio-dev <nio-...@openjdk.java.net> Cc: OpenJDK Network Dev list <net-dev@openjdk.java.net> Subject: Re: RFR: 8231260: (dc) DatagramChannel::disconnect changes the port of the local address to 0 (lnx) On 08/10/2019 15:29, Alan Bateman wrote: > On 08/10/2019 15:20, mark sheppard wrote: >> : >> >> Q: is localAddress.getPort() == 0 indicative that the >> DatagramChannel is unbound ? >> > getLocalAddress() returns a SocketAddress when bound, it returns null > when not bound. I don't think we should get too hung up on corner case > that arises when the local port cannot be restored (by re-binding). The > javadoc sets the expectations that the channel's socket is in an > undefined state when disconnect fails. +1 : you would be in uncharted territory and that's exactly why we want to throw an exception when rebind fails and why we recommend closing the channel when that happens. -- daniel > > -Alan.