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

ServerSocket constructor needs to use anyLocalAddress in place of getLocalHost

XMLWordPrintable

    • 1.0prebeta2
    • sparc
    • generic
    • Not verified

      From ###@###.### (Pavani Diwanji)
      Newsgroups: fp.java-interest
      Subject: Re: How to bind a socket in Java beta release
      Date: 3 Oct 1995 19:07:55 GMT

      > Unfortunately, socket.bindToPort() is gone, and there is no equivalent
      > in ServerSocket. Looking at the code in ServerSocket.java and InetAddress.java,
      > It seems that ms that the local address is gotten from
      > private static native String getLocalHostName(),
      > which I have no control over.

      You have a very valid point. I think in the next revision of the api,
      we should add a constructor to ServerSocket for letting you specify an
      InetAddress explicitly.

      Though I think the correct way to go for multihomed servers is not to
      explicitly specify interface address they are listening on, but to make
      use of INADDR_ANY (local ip address wild card).

      I think for now, I will file a bug so that existing ServerSocket(port, count)
      constructor will actually bind not using getLocalHost but anyLocalAddress
      instead. This will let people like you do multihomed servers with
      existing API.

      Pavani.

            duke J. Duke
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: