#include <curl/curl.h> CURLcode curl_easy_send( CURL * curl , const 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 and stores the number of bytes sent into n. This may be less than the amount that was requested to send. On failure, returns the appropriate error code.
This function sends arbitrary data over the established connection. It may be used together with
curl_easy_recv(3) to implement custom protocols using libcurl.
The functionality can be particularly useful if using proxies and/or SSL encryption: libcurl will handle the proxy negotiation and connection setup.
buffer is a pointer to the data of length buflen that is to be sent. The variable n points to will receive the number of sent bytes.
To establish the connection, set the
CURLOPT_CONNECT_ONLY option before calling
curl_easy_perform(3). Note that
curl_easy_send(3) will not work on connections that were created without this option.
Ensure that the socket is writable before calling
curl_easy_send, otherwise the call will return
CURLE_AGAIN - the socket is used in non-blocking mode internally.
CURLINFO_LASTSOCKET to obtain the socket; use your operating system
facilities such as select to check if it can be written to.
2013/05/08 Automated cleanup pass.
2012/05/04 Initial version.