System.Net.Socket.TSocket.Send

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Send(const Buf; Count: Integer; Flags: Integer): Integer; overload;
function Send(const Buf; Count: Integer; Flags: TSocketFlags = []): Integer; overload; inline;
function Send(const S: string; Flags: TSocketFlags = []): Integer; overload;
function Send(const B: TBytes; Offset: Integer = 0; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload;
function Send(const B: array of Byte; Offset: Integer = 0; Count: Integer = -1; Flags: TSocketFlags = []): Integer; overload;

C++

int __fastcall Send(const void *Buf, int Count, int Flags)/* overload */;
int __fastcall Send(const void *Buf, int Count, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall Send(const System::UnicodeString S, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall Send(const System::DynamicArray<System::Byte> B, int Offset = 0x0, int Count = 0xffffffff, TSocketFlags Flags = TSocketFlags() )/* overload */;
int __fastcall Send(System::Byte const *B, const int B_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

Sends the specified data to the connected endpoint.

You may pass Send 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 Send. For more information, see the documentation of the send function in the MSDN.

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, Send returns the number of bytes that were sent. If your socket is not connected, Send returns -1.

Exceptions

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

Exception Exception.Message Scenarios

ESocketError

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

Socket type not compatible with call

See Also