System.Net.Socket.TSocket.SendTo
Delphi
function SendTo(const Buf; Count: Integer; Flags: Integer): Integer; overload; inline;
function SendTo(const Buf; Count: Integer; Flags: TSocketFlags = []): Integer; overload; inline;
function SendTo(const S: string; Flags: TSocketFlags = []): Integer; overload; inline;
function SendTo(const B: array of Byte; Offset: Integer = 0; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload;
function SendTo(const Buf; Count: Integer; const Endpoint: TNetEndpoint; Flags: Integer): Integer; overload;
function SendTo(const Buf; Count: Integer; const Endpoint: TNetEndpoint; Flags: TSocketFlags = []): Integer; overload; inline;
function SendTo(const S: string; const Endpoint: TNetEndpoint; Flags: TSocketFlags = []): Integer; overload;
function SendTo(const B: array of Byte; const Endpoint: TNetEndpoint; Offset: Integer = 0; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload;
C++
int __fastcall SendTo(const void *Buf, int Count, int Flags)/* overload */;
int __fastcall SendTo(const void *Buf, int Count, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall SendTo(const System::UnicodeString S, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall SendTo(System::Byte const *B, const int B_High, int Offset = 0x0, int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall SendTo(const void *Buf, int Count, const TNetEndpoint &Endpoint, int Flags)/* overload */;
int __fastcall SendTo(const void *Buf, int Count, const TNetEndpoint &Endpoint, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall SendTo(const System::UnicodeString S, const TNetEndpoint &Endpoint, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall SendTo(System::Byte const *B, const int B_High, const 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
Sends the specified data to the specified endpoint.
You may pass SendTo the following parameters:
Bufis a pointer to a buffer that contains the data to send.Offsetis a number of bytes to skip at the beginning of the data to send.Countis the length (in bytes) of the buffer pointed byBuf, which is also the maximum length of the data to send.Flagsis a set of flags that influence the behavior of SendTo. For more information, see the documentation of the send function in the MSDN.Endpointis the target endpoint.
Instead of providing a pointer to a buffer (Buf), you may provide a string (S) or an array of bytes (B).
If the specified data is sent successfully, SendTo returns the number of bytes that were sent. If your socket is not connected, SendTo returns -1.
Exceptions
A call to SendTo can raise any of the following exceptions:
| Exception | Exception.Message | Scenarios |
|---|---|---|
|
Network socket error: <error message> (<error code>), on API 'sendto' |
|
See Also
- sendto function (MSDN)