E
E
Everything curl
Search…
sockopt
The sockopt callback is set with CURLOPT_SOCKOPTFUNCTION:
1
curl_easy_setopt(handle, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
Copied!
The sockopt_callback function must match this prototype:
1
int sockopt_callback(void *clientp,
2
curl_socket_t curlfd,
3
curlsocktype purpose);
Copied!
This callback function gets called by libcurl when a new socket has been created but before the connect call, to allow applications to change specific socket options.
The clientp pointer points to the private data set with CURLOPT_SOCKOPTDATA:
1
curl_easy_setopt(handle, CURLOPT_SOCKOPTDATA, custom_pointer);
Copied!
This callback should return:
    CURL_SOCKOPT_OK on success
    CURL_SOCKOPT_ERROR to signal an unrecoverable error to libcurl
    CURL_SOCKOPT_ALREADY_CONNECTED to signal success but also that the socket is
    in fact already connected to the destination
Last modified 1yr ago
Export as PDF
Copy link