![]() |
![]()
| ![]() |
![]()
NAMECURLOPT_SOCKOPTFUNCTION - callback for setting socket options SYNOPSIS#include <curl/curl.h> typedef enum { DESCRIPTIONPass a pointer to your callback function, which should match the prototype shown above. When set, this callback function gets called by libcurl when the socket has been created, but before the connect call to allow applications to change specific socket options. The callback's purpose argument identifies the exact purpose for this particular socket: CURLSOCKTYPE_IPCXN for actively created connections or since 7.28.0 CURLSOCKTYPE_ACCEPT for FTP when the connection was setup with PORT/EPSV (in earlier versions these sockets were not passed to this callback). Future versions of libcurl may support more purposes. libcurl passes the newly created socket descriptor to the callback in the curlfd parameter so additional setsockopt() calls can be done at the user's discretion. The clientp pointer contains whatever user-defined value set using the CURLOPT_SOCKOPTDATA(3) function. Return CURL_SOCKOPT_OK from the callback on success. Return CURL_SOCKOPT_ERROR from the callback function to signal an unrecoverable error to the library and it closes the socket and returns CURLE_COULDNT_CONNECT. Alternatively, the callback function can return CURL_SOCKOPT_ALREADY_CONNECTED, to tell libcurl that the socket is already connected and then libcurl does no attempt to connect. This allows an application to pass in an already connected socket with CURLOPT_OPENSOCKETFUNCTION(3) and then have this function make libcurl not attempt to connect (again). DEFAULTNULL PROTOCOLSThis functionality affects all supported protocols EXAMPLE/* make libcurl use the already established socket 'sockfd' */ static curl_socket_t opensocket(void *clientp, AVAILABILITYAdded in curl 7.16.0 RETURN VALUEcurl_easy_setopt(3) returns a CURLcode indicating success or error. CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). SEE ALSOCURLOPT_OPENSOCKETFUNCTION(3), CURLOPT_SEEKFUNCTION(3), CURLOPT_SOCKOPTDATA(3)
|