System.Net.Socket.TSocket.Receive
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::Sysutils::TBytes __fastcall Receive(int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall Receive(/* out */ System::Sysutils::TBytes &Bytes, int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall Receive(System::Byte *Bytes, const System::NativeInt 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 byBuf
, which is also the maximum length of the requested data that Receive returns. IfCount
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 |
---|---|---|
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
- System.Net.Socket.TSocket.ReceiveLength
- System.Net.Socket.TSocket.ReceiveFrom
- System.Net.Socket.TSocket.Send
- System.Net.Socket.TSocket.BeginReceive
- System.Net.Socket.TSocket.EndReceiveString
- System.Net.Socket.TSocket.EndReceiveBytes
- recv function (MSDN)