System.Net.Socket.TSocket.Receive

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Receive(var Buf; Count: Integer; Flags: Integer): Integer; overload;
function Receive(var Buf; Count: Integer; Flags: TSocketFlags = []): Integer; overload; inline;
function Receive(Count: Integer = -1; Flags: TSocketFlags = []): TBytes; overload; inline;
function Receive(out Bytes: TBytes; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload;
function Receive(var Bytes: array of Byte; Offset: Integer = 0; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload;

C++

int __fastcall Receive(void *Buf, int Count, int Flags)/* overload */;
int __fastcall Receive(void *Buf, int Count, TSocketFlags Flags = TSocketFlags() )/* overload */;
System::DynamicArray<System::Byte> __fastcall Receive(int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall Receive(/* out */ System::DynamicArray<System::Byte> &Bytes, int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall Receive(System::Byte *Bytes, const int Bytes_High, int Offset = 0x0, int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.Net.Socket.pas
System.Net.Socket.hpp
System.Net.Socket TSocket

Description

Obtains data sent from the connected endpoint.

Receive blocks the caller until it returns the requested data.

You may pass Receive the following parameters:

  • Buf is a pointer to the buffer to receive the incoming data.
  • Offset is a number of bytes to skip at the beginning of the requested data.
  • Count is the length (in bytes) of the buffer pointed by Buf, which is also the maximum length of the requested data that Receive returns. If Count is -1, Receive returns the length (in bytes) of the received data.
  • Flags is a set of flags that influence the behavior of Receive. For more information, see the documentation of the recv function in the MSDN.

Instead of providing a pointer to a buffer (Buf), you may either provide no such argument and let Receive return the requested data, or provide an output parameter, Bytes, that Receive can fill with the requested data. In both cases, the returned data never amounts to more than the specified Count of bytes.

Exceptions

A call to Receive can raise any of the following exceptions:

Exception Exception.Message Scenarios

ESocketError

Network socket error: <error message> (<error code>), on API 'ioctlsocket'

Network socket error: <error message> (<error code>), on API 'recv'

Socket type not compatible with call

See Also