Read data from a socket.
[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 SocketRead call. buffer_maxlen cannot exceed INT_MAX (2147483647).
[in] Data reading timeout in milliseconds. If data is not obtained within this time, attempts are stopped and the function returns -1.
If successful, return the number of read bytes. 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 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".