Receive From Async(SocketAsyncEventArgs) Method
Begins to asynchronously receive data from a specified network device.
public: bool ReceiveFromAsync(System::Net::Sockets::SocketAsyncEventArgs ^ e);
public bool ReceiveFromAsync (System.Net.Sockets.SocketAsyncEventArgs e);
member this.ReceiveFromAsync : System.Net.Sockets.SocketAsyncEventArgs -> bool
Public Function ReceiveFromAsync (e As SocketAsyncEventArgs) As Boolean
The SocketAsyncEventArgs object to use for this asynchronous socket operation.
true if the I/O operation is pending. The Completed event on the
e parameter will be raised upon completion of the operation.
false if the I/O operation completed synchronously. In this case, The Completed event on the
e parameter will not be raised and the
e object passed as a parameter may be examined immediately after the method call returns to retrieve the result of the operation.
A socket operation was already in progress using the SocketAsyncEventArgs object specified in the
Windows XP or later is required for this method.
An error occurred when attempting to access the socket.
The ReceiveFromAsync method is used primarily to receive data on a connectionless socket. The socket's local address must be known.
The SocketAsyncEventArgs.SocketFlags property on the
e parameter provides the Window Sockets service provider with additional information about the read request. For more information about how to use this parameter, see System.Net.Sockets.SocketFlags.
The following properties and events on the System.Net.Sockets.SocketAsyncEventArgs object are required to successfully call this method:
The caller may set the SocketAsyncEventArgs.UserToken property to any user state object desired before calling the ReceiveFromAsync method, so that the information will be retrievable in the callback method. If the callback needs more information than a single object, a small class can be created to hold the other required state information as members.
For message-oriented sockets, an incoming message is placed into the buffer up to the total size of the buffer. The SocketAsyncEventArgs.Count and SocketAsyncEventArgs.Offset properties determine where in the buffer the data is placed and the amount of data.
For byte stream-style sockets, incoming data is placed into the buffer until the buffer is filled, the connection is closed, or the internally buffered data is exhausted. The SocketAsyncEventArgs.Count and SocketAsyncEventArgs.Offset properties determine where in the buffer the data is placed and the amount of data.