#include <curl/curl.h> CURLcode curl_easy_recv( CURL * curl , void * buffer , size_t buflen , size_t * n );
|curl||Handle to a curl session.|
|buffer||Pointer to a buffer that the data will be received into.|
|buflen||Length of the buffer.|
|n||Pointer to the number of received bytes.|
On success, returns
CURLE_OK, stores the received data into buffer, and the number of bytes it read into n.
On failure, returns the appropriate error code.
If there is no data to read, the function returns
CURLE_AGAIN. Use available operating system facilities to wait until the data is ready and then retry.
This function receives raw data from the established connection. Use it together with
curl_easy_send to implement custom protocols using libcurl.
This functionality can be useful when using proxies and/or SSL encryption: libcurl will take care of proxy negotiation and connection setup.
buffer is a pointer to the buffer that will get the received data. buflen is the maximum amount of data available in that buffer. The variable n points to receives the number of received bytes.
To establish the connection, set
CURLOPT_CONNECT_ONLY option before calling
curl_easy_recvdoes not function on connections that were created without this option.
Ensure that the socket has data to read before calling
curl_easy_recv, otherwise the call will return
CURLE_AGAIN - the socket is used in non-blocking mode internally.
CURLINFO_LASTSOCKET to obtain the socket; use available operating system facilities, such as select, to
check if there is any data that can be read.
2013/05/08 Automated cleanup pass.
2012/05/04 Initial version.