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

System.Net.Sockets.NetworkStream.EndRead Method

Ends an asynchronous call to read data from the current instance. [Edit]

public override int EndRead (IAsyncResult ar)

Parameters

ar
A IAsyncResult object that holds the state information for the asynchronous operation. [Edit]

Returns

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

Exceptions

TypeReason
ArgumentNullExceptionasyncResult is null. [Edit]
System.IO.IOException
Note: This method catches all exceptions thrown by the Socket.EndReceive(IAsyncResult) method.
[Edit]
ObjectDisposedExceptionThe current instance has been disposed. [Edit]

Remarks

This method blocks if the asynchronous operation has not completed.

The NetworkStream.EndRead(IAsyncResult) method completes an asynchronous request that was started with a call to the NetworkStream.BeginRead(Byte[], int, int, AsyncCallback, object) method. The object specified for the asyncResult parameter is required to be the same object as was returned by the NetworkStream.BeginRead(Byte[], int, int, AsyncCallback, object) method call that began the request.

If the NetworkStream.EndRead(IAsyncResult) method is invoked via the AsyncCallback delegate specified to the NetworkStream.BeginRead(Byte[], int, int, AsyncCallback, object) method, the asyncResult parameter is the IAsyncResult argument passed to the delegate's method.

Note:

This method overrides System.IO.Stream.EndRead(IAsyncResult).

[Edit]

Example

For an outline of an asynchronous operation, see the Socket.BeginAccept(AsyncCallback, object) method. For the complete example, see the System.Net.Sockets.Socket class overview.

Requirements

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