1CURLOPT_CLOSESOCKETFUNCTION(c3u)rl_easy_setopt optioCnUsRLOPT_CLOSESOCKETFUNCTION(3)
2
3
4

NAME

6       CURLOPT_CLOSESOCKETFUNCTION - callback to socket close replacement
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       int closesocket_callback(void *clientp, curl_socket_t item);
12
13       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CLOSESOCKETFUNCTION,
14                                 closesocket_callback);
15

DESCRIPTION

17       Pass a pointer to your callback function, which should match the proto‐
18       type shown above.
19
20       This callback function gets called by libcurl instead of  the  close(3)
21       or  closesocket(3) call when sockets are closed (not for any other file
22       descriptors). This is pretty much the reverse to the  CURLOPT_OPENSOCK‐
23       ETFUNCTION(3)  option. Return 0 to signal success and 1 if there was an
24       error.
25
26       The clientp pointer is set with CURLOPT_CLOSESOCKETDATA(3). item is the
27       socket libcurl wants to be closed.
28

DEFAULT

30       By default libcurl uses the standard socket close function.
31

PROTOCOLS

33       All
34

EXAMPLE

36       static int closesocket(void *clientp, curl_socket_t item)
37       {
38         printf("libcurl wants to close %d now\n", (int)item);
39         return 0;
40       }
41
42       /* call this function to close sockets */
43       curl_easy_setopt(curl, CURLOPT_CLOSESOCKETFUNCTION, closesocket);
44       curl_easy_setopt(curl, CURLOPT_CLOSESOCKETDATA, &sockfd);
45

AVAILABILITY

47       Added in 7.21.7
48

RETURN VALUE

50       Returns  CURLE_OK  if the option is supported, and CURLE_UNKNOWN_OPTION
51       if not.
52

SEE ALSO

54       CURLOPT_CLOSESOCKETDATA(3), CURLOPT_OPENSOCKETFUNCTION(3),
55
56
57
58libcurl 7.82.0                 November 26, 2021CURLOPT_CLOSESOCKETFUNCTION(3)
Impressum