Begins to asynchronously receive data from a connected System.Net.Sockets.Socket.
- socket_flags
- Documentation for this section has not yet been entered.
- buffer
- An array of type byte that is the storage location for the received data.
- offset
- The zero-based position in the buffer parameter at which to store the received data.
- size
- The number of bytes to receive.
- callback
- An AsyncCallback delegate that references the method to invoke when the operation is complete.
- state
- A user-defined object that contains information about the receive operation. This object is passed to the Socket.EndReceive(IAsyncResult) delegate when the operation is complete.
An IAsyncResult that references the asynchronous read.
Type Reason ArgumentNullException buffer is null. ArgumentOutOfRangeException offset < 0.
-or-
offset > buffer.Length.
-or-
size < 0.
-or-
size > buffer.Length - offset.
System.Net.Sockets.SocketException socketFlags is not a valid combination of values.
-or-
An error occurred while accessing the socket.
Note: For additional information on causes of the SocketException, see the System.Net.Sockets.SocketException class.ObjectDisposedException The current instance has been disposed.
The asynchronous Socket.BeginReceive(Byte[], int, int, SocketFlags, AsyncCallback, object) operation must be completed by calling the Socket.EndReceive(IAsyncResult) method. Typically, the method is invoked by the callback delegate.
This method does not block until the operation is complete. To block until the operation is complete, use one of the erload:System.Net.Sockets.Socket.Receive method overloads.
To cancel a pending erload:System.Net.Sockets.Socket.BeginReceive, call the Socket.Close method.
For detailed information about using the asynchronous programming model, see Asynchronous Programming Overview.
If you receive a System.Net.Sockets.SocketException, use the SocketException.ErrorCode property to obtain the specific error code. After you have obtained this code, refer to the Windows Sockets version 2 API error code documentation in the MSDN library for a detailed description of the error.
All I/O initiated by a given thread is canceled when that thread exits. A pending asynchronous operation can fail if the thread exits before the operation completes.
state is an instantiation of a user-defined class.
This member outputs trace information when you enable network tracing in your application. For more information, see [<topic://conUsingNetworkTracing>].
The execution context (the security context, the impersonated user, and the calling context) is cached for the asynchronous System.Net.Sockets.Socket methods. After the first use of a particular context (a specific asynchronous System.Net.Sockets.Socket method, a specific System.Net.Sockets.Socket instance, and a specific callback), subsequent uses of that context will see a performance improvement.