Receives a datagram in a specific location in the data buffer and stores the endpoint.
[Visual Basic]
Overridable Overloads Public Function ReceiveFrom( _
ByVal buffer As Byte(), _
ByVal offset As Integer, _
ByVal size As Integer, _
ByVal socketFlags As SocketFlags, _
ByRef remoteEP As EndPoint _
) As Integer
The number of bytes received.
If you use a connectionless protocol, the remoteEP parameter contains the EndPoint associated with the Socket that sent the data. If you use a connection-oriented protocol, remoteEP is left unchanged. You must set the LocalEndPoint property before calling this method. When no incoming data is available, and the Blocking property is false, a SocketException is thrown. When Blocking is true, this method blocks and waits for data to arrive. For Stream Socket types, if the remote Socket was shut down gracefully, and all data was received, this method immediately returns zero, regardless of the blocking state.
If you are using a message-oriented Socket, and the message is larger than the size of the buffer parameter, then buffer is filled with the first part of the message, and a SocketException is thrown. With unreliable protocols the excess data is lost; with reliable protocols, the data is retained by the service provider.
When the OutOfBand flag is specified as the socketFlags parameter and the Socket is configured for in-line reception of out-of-band (OOB) data (using OutOfBandInline) and OOB data is available, only OOB data is returned. When the SocketFlags. Peek flag is specified as the socketFlags parameter, available data is copied into the receive buffer but not removed from the system buffer.
Exception Type | Condition |
---|---|
ArgumentNullException | buffer is a null reference (Nothing in Visual Basic). |
ArgumentOutOfRangeException | The specified offset or size exceeds the size of buffer. |
SocketException | An operating system error occurs while accessing the VirtualSocket. |
ObjectDisposedException | The VirtualSocket has been closed. |
VirtualSocket Class | VirtualSocket Members | Org.Mentalis.Security.Ssl Namespace | VirtualSocket.ReceiveFrom Overload List