Receive Method (Byte[], Int32, SocketFlags)
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Receives the specified number of bytes of data from a bound Socket into a receive buffer, using the specified SocketFlags.
Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Syntax
'Declaration
Public Function Receive ( _
buffer As Byte(), _
size As Integer, _
socketFlags As SocketFlags _
) As Integer
public int Receive(
byte[] buffer,
int size,
SocketFlags socketFlags
)
public:
int Receive(
array<unsigned char>^ buffer,
int size,
SocketFlags socketFlags
)
member Receive :
buffer:byte[] *
size:int *
socketFlags:SocketFlags -> int
public function Receive(
buffer : byte[],
size : int,
socketFlags : SocketFlags
) : int
Parameters
- buffer
Type: array<System. . :: . .Byte> [] () [] []
An array of type Byte that is the storage location for the received data.
- size
Type: System. . :: . .Int32
The number of bytes to receive.
- socketFlags
Type: System.Net.Sockets. . :: . .SocketFlags
A bitwise combination of the SocketFlags values.
Return Value
Type: System. . :: . .Int32
The number of bytes received.
Remarks
The Receive method reads data into the buffer parameter and returns the number of bytes successfully read. You can call Receive from both connection-oriented and connectionless sockets.
This overload only requires you to provide a receive buffer, the number of bytes you want to receive, and the necessary SocketFlags.
If no data is available for reading, the Receive method will block until data is available, unless a time-out value was set by using Socket..::..ReceiveTimeout. If the time-out value was exceeded, the Receive call will throw a SocketException. If you are in non-blocking mode, and there is no data available in the in the protocol stack buffer, The Receive method will complete immediately and throw a SocketException. You can use the Available property to determine if data is available for reading. When Available is non-zero, retry your receive operation.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.