Mono Class Library: System.Net.Sockets.NetworkStream Overview | Members

System.Net.Sockets.NetworkStream.Read Method

Reads data from the current instance and stores it in a data buffer. [Edit]

public override int Read (byte[] buffer, int offset, int size)

Parameters

buffer
A byte array to store data read from the stream. [Edit]
offset
A int containing the zero-based position in buffer at which to begin storing the data. [Edit]
size
A int containing the number of bytes to read. [Edit]

Returns

A int containing the number of bytes read from the stream. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionbuffer is null. [Edit]
ArgumentOutOfRangeException

offset < 0.

-or-

offset > buffer.Length.

-or-

size < 0.

-or-

size > buffer.Length - offset.

[Edit]
System.IO.IOException
Note: This method catches all exceptions thrown by the Socket.Receive(Byte[], int, SocketFlags) method.
[Edit]
ObjectDisposedExceptionThe current instance has been disposed. [Edit]

Remarks

When no incoming data is available, this method blocks and waits for data to arrive.

If the remote socket was shut down gracefully (Socket.Shutdown(SocketShutdown) was called on the socket or the SocketOptionName.Linger option was enabled and Socket.Close was called on the socket) and all data was received, this method immediately returns zero.

Note:

This method overrides System.IO.Stream.Read(Byte[], int, int).

[Edit]

Requirements

Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0