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

Socket.getInputStream().available() not clear for case that connection is shutdown for reading

    XMLWordPrintable

Details

    • b06
    • generic
    • generic, linux
    • Verified

    Description

      This thread on the net-dev list:

      http://mail.openjdk.java.net/pipermail/net-dev/2011-January/002607.html

      highlights the issue that it's not cler what Socket.getInputStream().available() should return when the Socket's input has been shutdown with shutdownInput.

      With the default SocketImpl then available() will return the number of bytes in the socket buffer but that may be confusing as those bytes cannot be read. It may be tempting to change the implementation to return 0 but this could potentially break applications that would otherwise read EOF. Also it may not be possible to do that anyway because it's not clear how alternative SocketImpls behave. One possibility is to add a clarification (in both Socket#getInputStream and Socket#shutdownInput) to say that the return value from available() is SocketImpl specific when the input is shutdown, it may or may not return the number of bytes in the socket buffer.

      Attachments

        Issue Links

          Activity

            People

              chegar Chris Hegarty
              alanb Alan Bateman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: