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

NAME

6       CURLOPT_CLOSESOCKETFUNCTION  -  callback  to  socket  close replacement
7       function
8

SYNOPSIS

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

DESCRIPTION

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

DEFAULT

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

PROTOCOLS

34       All
35

EXAMPLE

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

AVAILABILITY

48       Added in 7.21.7
49

RETURN VALUE

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

SEE ALSO

55       CURLOPT_CLOSESOCKETDATA(3), CURLOPT_OPENSOCKETFUNCTION(3),
56
57
58
59libcurl 7.71.1                  March 23, 2020  CURLOPT_CLOSESOCKETFUNCTION(3)
Impressum