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

{Socket,ServerSocket}.setReuseAddress need to be re-specified

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • None
    • rc1
    • generic
    • generic


      The specification for {Server,ServerSocket}.setReuseAddress
      currently states :-

           * The SO_REUSEADDR socket option affects the <code>bind()</code>
           * operation and serves 2 main different purposes:
           * <UL>
           * <LI>Allows a listening server to start and <code>bind</code> its port
           * even if previously established connections exists that use this port
           * as their local port. This typically happens when a ServerSocket is
           * started and listen on that port, accepts an incoming connection and
           * spawn a child process to handle the socket. Then the listening server
           * terminates but the child continues to service the client. At that, to
           * be able to restart the listening ServerSocket, the SO_REUSEADDR option
           * needs to be turned on.</LI>
           * <LI>Allows multiple instances of the same server to be started on
           * the same port, as long as each instance binds a different local
           * IP address.</LI>
           * </UL>


      This wording has proved difficult for those developing compatibility
      tests - the paragraph "Allows multiple instances ..." is in fact
      not correct as the SO_REUSEADDR socket option isn't required to
      co-exist sockets bind to different local addresses.

      Thus we need to :-

      1. Re-word the spec along the lines of the classic Stevens explaination.

      2. Remove section of spec dealing with "multiple instances" - this is
      esp. true for TCP sockets as there is too much variation in OS behaviour.

      3. Properly specify that SO_REUSEADDR should be enable prior to
      binding in order to bind to a socket address with a connection that still
      in time wait.

      4. Specify the default setting.

      5. Indicate that the behaviour as a result of enabling/disable after
      the socket is bound is not defined. This is OS specific so it cannot
      be specified.

      ###@###.### 2001-10-02

            alanb Alan Bateman
            alanb Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: