Sdílet prostřednictvím


Socket.InputStream Property

Definition

Returns an input stream for this socket.

public virtual System.IO.Stream? InputStream { [Android.Runtime.Register("getInputStream", "()Ljava/io/InputStream;", "GetGetInputStreamHandler")] get; }
[<get: Android.Runtime.Register("getInputStream", "()Ljava/io/InputStream;", "GetGetInputStreamHandler")>]
member this.InputStream : System.IO.Stream

Property Value

an input stream for reading bytes from this socket.

Attributes

Exceptions

if an error occurs while creating the input stream or the socket is in an invalid state.

Remarks

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 :-

<ul>

<li>

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 java.io.InputStream#read read.

<li>

If there are no bytes buffered on the socket, or all buffered bytes have been consumed by java.io.InputStream#read read, then all subsequent calls to java.io.InputStream#read read will throw an java.io.IOException IOException.

<li>

If there are no bytes buffered on the socket, and the socket has not been closed using #close close, then java.io.InputStream#available available will return 0.

</ul>

Closing the returned java.io.InputStream InputStream will close the associated socket.

Java documentation for java.net.Socket.getInputStream().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to