data$, n = easy:Recv(len)
len
.
To establish the connection, get #CURLOPT_CONNECT_ONLY
option before calling easy:Perform() or multi:Perform().
Note that easy:Recv()
does not work on connections that were created without this option.
The call will return -1 in n
if there is no data to read - the socket is used in non-blocking mode internally. When
-1 is returned, sleep for a few milliseconds to wait for data. You should sleep for a few seconds only if easy:Recv()
returns -1 in n
. The reason for this is libcurl or the SSL library may internally cache some data, therefore you should call
easy:Recv()
until all data is read which would include any cached data.
Furthermore, easy:Recv()
may return -1 in n
if the only data that was read was for internal SSL processing, and no other
data is available.