Mentalis.org Security Library documentation

VirtualSocket.ReceiveFrom Method (Byte[], Int32, Int32, SocketFlags, EndPoint)

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
[C#]
public virtual int ReceiveFrom(
   byte[] buffer,
   int offset,
   int size,
   SocketFlags socketFlags,
   ref EndPoint remoteEP
);

Parameters

buffer
The storage location for received data.
offset
The position in the buffer parameter to store the received data.
size
The number of bytes to receive.
socketFlags
A bitwise combination of the SocketFlags values.
remoteEP
An EndPoint, passed by reference, that represents the remote server.

Return Value

The number of bytes received.

Remarks

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.

Exceptions

Exception TypeCondition
ArgumentNullExceptionbuffer is a null reference (Nothing in Visual Basic).
ArgumentOutOfRangeExceptionThe specified offset or size exceeds the size of buffer.
SocketExceptionAn operating system error occurs while accessing the VirtualSocket.
ObjectDisposedExceptionThe VirtualSocket has been closed.

See Also

VirtualSocket Class | Org.Mentalis.Security.Ssl Namespace | VirtualSocket.ReceiveFrom Overload List