Ends an asynchronous call to read data from the current instance.
- ar
- A IAsyncResult object that holds the state information for the asynchronous operation.
A int containing the number of bytes read from the stream.
Type Reason ArgumentNullException asyncResult is null. System.IO.IOException Note: This method catches all exceptions thrown by the Socket.EndReceive(IAsyncResult) method.ObjectDisposedException The current instance has been disposed.
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).
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.
Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0