System.Net.Socket.TSocket.ReceiveFrom
Delphi
function ReceiveFrom(var Buf; Count: Integer; Flags: Integer): Integer; overload;
function ReceiveFrom(var Buf; Count: Integer; Flags: TSocketFlags = []): Integer; overload; inline;
function ReceiveFrom(Count: Integer = -1; Flags: TSocketFlags = []): TBytes; overload; inline;
function ReceiveFrom(out Bytes: TBytes; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload; inline;
function ReceiveFrom(var Bytes: array of Byte; Offset: Integer = 0; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload;
function ReceiveFrom(var Buf; Count: Integer; out Endpoint: TNetEndpoint; Flags: Integer): Integer; overload;
function ReceiveFrom(var Buf; Count: Integer; out Endpoint: TNetEndpoint; Flags: TSocketFlags = []): Integer; overload; inline;
function ReceiveFrom(out Endpoint: TNetEndpoint; Count: Integer = -1; Flags: TSocketFlags = []): TBytes; overload; inline;
function ReceiveFrom(out Bytes: TBytes; out Endpoint: TNetEndpoint; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload;
function ReceiveFrom(var Bytes: array of Byte; out Endpoint: TNetEndpoint; Offset: Integer = 0; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload;
C++
int __fastcall ReceiveFrom(void *Buf, int Count, int Flags)/* overload */;
int __fastcall ReceiveFrom(void *Buf, int Count, TSocketFlags Flags = TSocketFlags() )/* overload */;
System::DynamicArray<System::Byte> __fastcall ReceiveFrom(int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall ReceiveFrom(/* out */ System::DynamicArray<System::Byte> &Bytes, int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall ReceiveFrom(System::Byte *Bytes, const int Bytes_High, int Offset = 0x0, int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall ReceiveFrom(void *Buf, int Count, /* out */ TNetEndpoint &Endpoint, int Flags)/* overload */;
int __fastcall ReceiveFrom(void *Buf, int Count, /* out */ TNetEndpoint &Endpoint, TSocketFlags Flags = TSocketFlags() )/* overload */;
System::DynamicArray<System::Byte> __fastcall ReceiveFrom(/* out */ TNetEndpoint &Endpoint, int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall ReceiveFrom(/* out */ System::DynamicArray<System::Byte> &Bytes, /* out */ TNetEndpoint &Endpoint, int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall ReceiveFrom(System::Byte *Bytes, const int Bytes_High, /* out */ TNetEndpoint &Endpoint, 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
Receives data from a remote socket.
In order to use ReceiveFrom, the type of your socket must be either TCP or UDP.
ReceiveFrom blocks the caller until it returns the requested data.
You may pass ReceiveFrom the following parameters:
Bufis a pointer to the buffer to receive the incoming data.Offsetis a number of bytes to skip at the beginning of the requested data.Countis the length (in bytes) of the buffer pointed byBuf, which is also the maximum length of the requested data that ReceiveFrom returns.Flagsis a set of flags that influence the behavior of ReceiveFrom. For more information, see the documentation of the recvfrom function in the MSDN.
The Endpoint output parameter indicates the source end point that sends the data.
Instead of providing a pointer to a buffer (Buf), you may either provide no such argument and let ReceiveFrom return the requested data, or provide an output parameter, Bytes, that ReceiveFrom 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 ReceiveFrom can raise any of the following exceptions:
| Exception | Exception.Message | Scenarios |
|---|---|---|
|
Network socket error: <error message> (<error code>), on API 'ioctlsocket' |
| |
|
Network socket error: <error message> (<error code>), on API 'recvfrom' |
|
See Also
- System.Net.Socket.TSocket.BeginReceiveFrom
- System.Net.Socket.TSocket.EndReceiveBytesFrom
- System.Net.Socket.TSocket.EndReceiveStringFrom
- send function (MSDN)