Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8286646

Connect should not throw BindException if the socket is bound

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • core-libs
    • None
    • Fix Understood

      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.

            djelinski Daniel Jelinski
            djelinski Daniel Jelinski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: