Send data via secure TLS connection.

int  SocketTlsSend(
   int           socket,               // socket
   const uchar&  buffer[],             // data buffer
   uint          buffer_len            // buffer size



[in]  Socket handle returned by the SocketCreate function. When an incorrect handle is passed, the error 5270 (ERR_NETSOCKET_INVALIDHANDLE) is written to _LastError.


[in]  Reference to the uchar type array with the data to be sent.


[in]  'buffer' array size.

Return Value

If successful, return the number of bytes written to a socket. In case of an error, -1 is returned.


If an error occurs on a system socket when executing the function, connection established via SocketConnect is discontinued.

In case of a data writing error, the error 5273 (ERR_NETSOCKET_IO_ERROR) is written to _LastError.

The function can be called only from Expert Advisors and scripts, as they run in their own execution threads. If calling from an indicator, GetLastError() returns the error 4014 – "Function is not allowed for call".

See also

SocketTimeouts, MathSwap, StringToCharArray