Noticed in JDK-8286372
A call to Socket.connect may throw BindException even if the socket is already bound. Bind exception is documented as follows:
"Signals that an error occurred while attempting to bind a socket to a local address and port. Typically, the port is in use, or the requested local address could not be assigned."
Using BindException on an already-bound socket appears to be inappropriate.
Internally, connect may return (WSA)EADDRINUSE on an unbound socket when the system is out of ephemeral ports, and on a bound socket when the combination of local and remote address is already in use, for example by a connection in TIME_WAIT state. The former case should still throw BindException, and the latter should be changed to throw ConnectException.
A call to Socket.connect may throw BindException even if the socket is already bound. Bind exception is documented as follows:
"Signals that an error occurred while attempting to bind a socket to a local address and port. Typically, the port is in use, or the requested local address could not be assigned."
Using BindException on an already-bound socket appears to be inappropriate.
Internally, connect may return (WSA)EADDRINUSE on an unbound socket when the system is out of ephemeral ports, and on a bound socket when the combination of local and remote address is already in use, for example by a connection in TIME_WAIT state. The former case should still throw BindException, and the latter should be changed to throw ConnectException.
- relates to
-
JDK-8286372 reuseAddress(true) dosen't work. throws address already in use BindException
-
- Closed
-