socket()
and the subsequent close()
of the same file descriptor.CURLOPT_OPENSOCKETFUNCTION
callback, you can provide a custom function to return a file descriptor for libcurl to use:opensocket_callback
function must match this prototype:CURLOPT_OPENSOCKETDATA
.CURLSOCKTYPE_IPCXN
or CURLSOCKTYPE_ACCEPT
, identifying in which circumstance the socket is created. The "accept" case being when libcurl is used to accept an incoming FTP connection for when FTP active mode is used, and all other cases when libcurl creates a socket for its own outgoing connections the IPCXN value is passed in.struct curl_sockaddr
that describes the IP address of the network destination for which this socket is created. Your callback can for example use this information to whitelist or blacklist specific addresses or address ranges.CURL_SOCKET_BAD
, which then will cause an unrecoverable error within libcurl and it will eventually return CURLE_COULDNT_CONNECT
from its perform function.curl_sockaddress
struct looks like this:closesocket_callback
function must match this prototype: