Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Receives data from a bound Socket into a receive buffer.
Namespace: System.Net.Sockets
Assembly: System (in System.dll)
Syntax
'Declaration
Public Function Receive ( _
buffer As Byte() _
) As Integer
public int Receive(
byte[] buffer
)
public:
int Receive(
array<unsigned char>^ buffer
)
member Receive :
buffer:byte[] -> int
public function Receive(
buffer : byte[]
) : int
Parameters
- buffer
Type: array<System. . :: . .Byte> [] () [] []
An array of type Byte that is the storage ___location for the received data.
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 buffer offset defaults to 0, the size defaults to the length of the buffer parameter, and the SocketFlags value defaults to None.
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 the receive operation.
If you are using a connectionless Socket, Receive will read the first queued datagram from the destination address you specify in the Connect method. If the datagram you receive is larger than the size of the buffer parameter, buffer gets filled with the first part of the message, the excess data is lost and a SocketException is thrown.
.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.