System.Net.Socket.TSocket.SendTo

From RAD Studio API Documentation
Jump to: navigation, search

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(const System::Byte *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(const System::Byte *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:

  • Buf is a pointer to a buffer that contains the data to send.
  • Offset is a number of bytes to skip at the beginning of the data to send.
  • Count is the length (in bytes) of the buffer pointed by Buf, which is also the maximum length of the data to send.
  • Flags is a set of flags that influence the behavior of SendTo. For more information, see the documentation of the send function in the MSDN.
  • Endpoint is 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

ESocketError

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

See Also