當前位置:編程學習大全網 - 編程軟體 - java最基礎網絡編程

java最基礎網絡編程

看看文檔就解決了

InputStream

java.net.Socket.getInputStream()

throws IOException

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.

最後壹行,關閉返回的輸入流將會關閉關聯的socket

  • 上一篇:腦電波編程
  • 下一篇:適合8壹12歲的室內遊戲
  • copyright 2024編程學習大全網