1CURLOPT_SOCKOPTDATA(3)     curl_easy_setopt options     CURLOPT_SOCKOPTDATA(3)
2
3
4

NAME

6       CURLOPT_SOCKOPTDATA - custom pointer to pass to sockopt callback
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode   curl_easy_setopt(CURL   *handle,  CURLOPT_SOCKOPTDATA,  void
12       *pointer);
13

DESCRIPTION

15       Pass a pointer that will be untouched by  libcurl  and  passed  as  the
16       first  argument  in  the sockopt callback set with CURLOPT_SOCKOPTFUNC‐
17       TION(3).
18

DEFAULT

20       The default value of this parameter is NULL.
21

PROTOCOLS

23       All
24

EXAMPLE

26       static int sockopt_callback(void *clientp, curl_socket_t curlfd,
27                                   curlsocktype purpose)
28       {
29         int val = *(int *)clientp;
30         setsockopt(curldfd, SOL_SOCKET, SO_RCVBUF, (const char *)&val, sizeof(val));
31         return CURL_SOCKOPT_OK;
32       }
33
34       curl = curl_easy_init();
35       if(curl) {
36         int recvbuffersize = 256 * 1024;
37
38         curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/");
39
40         /* call this function to set options for the socket */
41         curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
42         curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, &recvbuffersize);
43
44         res = curl_easy_perform(curl);
45
46         curl_easy_cleanup(curl);
47       }
48

AVAILABILITY

50       Added in 7.16.0
51

RETURN VALUE

53       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
54       if not.
55

SEE ALSO

57       CURLOPT_SOCKOPTFUNCTION(3), CURLOPT_OPENSOCKETFUNCTION(3),
58
59
60
61libcurl 7.66.0                   May 15, 2017           CURLOPT_SOCKOPTDATA(3)
Impressum