1CURLOPT_SOCKOPTDATA(3) curl_easy_setopt options CURLOPT_SOCKOPTDATA(3)
2
3
4
6 CURLOPT_SOCKOPTDATA - custom pointer to pass to sockopt callback
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKOPTDATA, void
12 *pointer);
13
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
20 The default value of this parameter is NULL.
21
23 All
24
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
50 Added in 7.16.0
51
53 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
54 if not.
55
57 CURLOPT_SOCKOPTFUNCTION(3), CURLOPT_OPENSOCKETFUNCTION(3),
58
59
60
61libcurl 7.61.1 May 15, 2017 CURLOPT_SOCKOPTDATA(3)