Returns an input stream for this socket.
If this socket has an associated channel then the resulting input
stream delegates all of its operations to the channel. If the channel
is in non-blocking mode then the input stream's read
operations
will throw an java.nio.channels.IllegalBlockingModeException
.
Under abnormal conditions the underlying connection may be broken by the remote host or the network software (for example a connection reset in the case of TCP connections). When a broken connection is detected by the network software the following applies to the returned input stream :-
The network software may discard bytes that are buffered
by the socket. Bytes that aren't discarded by the network
software can be read using read
.
If there are no bytes buffered on the socket, or all
buffered bytes have been consumed by
read
, then all subsequent
calls to read
will throw an
IOException
.
If there are no bytes buffered on the socket, and the
socket has not been closed using close
, then
available
will
return 0
.
Closing the returned InputStream
will close the associated socket.
IOException | if an I/O error occurs when creating the
input stream, the socket is closed, the socket is
not connected, or the socket input has been shutdown
using shutdownInput() |
@revised 1.4
@spec JSR-51
Diagram: Socket