Mentalis.org Security Library documentation

VirtualSocket.Receive Method (Byte[], Int32, SocketFlags)

Receives data from a connected VirtualSocket in a specific location of the receive buffer.

[Visual Basic]
Overridable Overloads Public Function Receive( _
   ByVal buffer As Byte(), _
   ByVal size As Integer, _
   ByVal socketFlags As SocketFlags _
) As Integer
[C#]
public virtual int Receive(
   byte[] buffer,
   int size,
   SocketFlags socketFlags
);

Parameters

buffer
The storage location for received data.
size
The number of bytes to receive.
socketFlags
A bitwise combination of the SocketFlags values.

Return Value

The number of bytes received.

Remarks

This overload only requires you to provide a receive buffer, the number of bytes you want to send, and the necessary SocketFlags. The offset defaults to 0.

The Blocking determines the behavior of this method when no incoming data is available. When false, a SocketException is thrown. When true, this method blocks and waits for data to arrive. For Stream Socket types, if the remote Socket was shut down gracefully, and all the 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, 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.

Note If you specify the OutOfBand flag as the socketFlags parameter, and the Socket is configured for in-line reception of out-of-band (OOB) data (using the OutOfBandInline option) and OOB data is available, then only OOB data is returned. When the Peek flag is specified as the socketFlags parameter, available data is copied into the receive buffer but is not removed from the system buffer.

Exceptions

Exception TypeCondition
ArgumentNullExceptionbuffer is a null reference (Nothing in Visual Basic).
ArgumentOutOfRangeExceptionThe 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.Receive Overload List