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

spec clarification: setReuseAddress still states that SO_REUSEADDR on by default

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • beta3
    • sparc
    • solaris_2.6



      Name: acR10002 Date: 08/16/2001



      The J2SE v1.4 API spec for ServerSocket.setReuseAddress(boolean on)
      specification reads:
      -----------------
      public void setReuseAddress(boolean on)
                           throws SocketException

           Enable/disable SO_REUSEADDR. This option is set to true by default
      when creating ServerSockets.
      ...
      -----------------

      However, in fact ReuseAddress is no longer true by default on Windows
      since the b75. The following example demonstrates the problem:

      ---------------- Test.java -------------
      import java.net.*;
      import java.io.IOException;

      public class Test {

          public static void main(String args[]) {
              try {
                  ServerSocket soc = new ServerSocket();
                  System.out.println("SO_REUSEADDR is " + soc.getReuseAddress()
      + " by default");
              } catch (IOException e) {
                  e.printStackTrace(System.out);
              }
          }
      }
      ---------------------------------------

      Test output under Windows 2000:

      # java -version
      java version "1.4.0-beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build
      1.4.0-beta_refresh-b75)
      Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b75, mixed mode)

      # java Test
      SO_REUSEADDR is false by default

      Everything was working fine in b74 and before:

      # java -version
      java version "1.4.0-beta_refresh"
      Java(TM) 2 Runtime Environment, Standard Edition (build
      1.4.0-beta_refresh-b74)
      Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b74, mixed mode)

      # java Test
      SO_REUSEADDR is true by default

      Please elimintate this inconsistency between the spec and implementation.


      ======================================================================

            alanb Alan Bateman
            aycsunw Ayc Ayc (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: