SocketTlsReadAvailable

Read all available data from secure TLS connection.

int  SocketTlsReadAvailable(
   int           socket,               // socket
   uchar&        buffer[],             // buffer for reading data from socket
   const uint    buffer_maxlen         // number of bytes to read
   );

Parameters

socket

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

buffer

[out]  Reference to the uchar type array the data is read in. Dynamic array size is increased by the number of read bytes. The array size cannot exceed INT_MAX (2147483647).

buffer_maxlen

[in]  Number of bytes to read to the buffer[] array. Data not fitting into the array remain in the socket. They can be received by the next SocketTlsReadAvailable or SocketTlsRead call. buffer_maxlen cannot exceed INT_MAX (2147483647).

Return Value

If successful, return the number of read bytes. In case of an error, -1 is returned.

Note

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

In case of a data reading error, the error 5273 (ERR_NETSOCKET_IO_ERROR) is written in _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