On Tue, 28 Nov 2023 18:49:53 GMT, Mark Sheppard <[email protected]> wrote:

> Returns: the local address to which the socket is bound, null if the socket 
> is closed, or an InetAddress representing 
> [wildcard](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/net/InetAddress.html#isAnyLocalAddress())
>  address if either the socket is not bound, or the security manager 
> checkConnect method does not allow the operation

DatagramSocket.getLocalAddress dates from JDK 1.1 and its odd behavior couldn't 
be changed for compatibility reasons. The newer 
DatagramSocket.getLocalSocketAddress is specified to return null when not bound.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/16635#issuecomment-1830492998

Reply via email to