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

java.net.ServerSocket.close() needs better documentation

XMLWordPrintable

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

      The only reasonable interpretation of ServerSocket.close() I can think of
      is to terminate a call to ServerSocket.accept() (in another thread) by throwing
      some kind of socket exception. As is pointed out by this poster to
      advanced-java, however, the documentation doesn't actually state that this is
      the intended behavior. We should fix the documentation.

      Date: Fri, 12 Jun 1998 18:33:21 -0400
      To: ###@###.### (Bill Foote), ###@###.###
      From: Mark Grand <###@###.###>
      Subject: Re: stopping ServerSocket.accept()??
      Mime-Version: 1.0

      At 03:09 PM 6/12/98 -0700, Bill Foote wrote:
      >I realize that the original question was for JDK 1.0.2, but I just wanted
      >to point out: In 1.1 and better, you can stop accept()ing sockets by calling
      >ServerSocket.close(). There's no need to set SO_TIMEOUT and check
      >a status variable.
      >
      >I just checked, and it works. The thread doing the accept() receives
      >this:
      >
      >java.net.SocketException: Socket closed

      Relying on SO_TIMEOUT is to rely on documented features. I am not aware of
      any official documentation that guarantees that a SocketException will be
      thrown in that case. A different SocketImpl may work differently.
      ------------------------------------------------------------
      Mark Grand (770)664-9903
      Java Consultant/Instructor ###@###.###
      http://www.mindspring.com/~mgrand
      Ask me about JAVA TRAINING and SUPPORT

            alanb Alan Bateman
            bfootesunw Bill Foote (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: