1CURLOPT_SOCKOPTDATA(3) curl_easy_setopt options CURLOPT_SOCKOPTDATA(3)
2
3
4
6 CURLOPT_SOCKOPTDATA - pointer to pass to sockopt callback
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKOPTDATA, void *pointer);
12
14 Pass a pointer that will be untouched by libcurl and passed as the
15 first argument in the sockopt callback set with CURLOPT_SOCKOPTFUNCâ
16 TION(3).
17
19 The default value of this parameter is NULL.
20
22 All
23
25 static int sockopt_callback(void *clientp, curl_socket_t curlfd,
26 curlsocktype purpose)
27 {
28 int val = *(int *)clientp;
29 setsockopt(curldfd, SOL_SOCKET, SO_RCVBUF, (const char *)&val, sizeof(val));
30 return CURL_SOCKOPT_OK;
31 }
32
33 curl = curl_easy_init();
34 if(curl) {
35 int recvbuffersize = 256 * 1024;
36
37 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
38
39 /* call this function to set options for the socket */
40 curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
41 curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, &recvbuffersize);
42
43 res = curl_easy_perform(curl);
44
45 curl_easy_cleanup(curl);
46 }
47
49 Added in 7.16.0
50
52 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
53 if not.
54
56 CURLOPT_SOCKOPTFUNCTION(3), CURLOPT_OPENSOCKETFUNCTION(3),
57
58
59
60libcurl 7.82.0 November 26, 2021 CURLOPT_SOCKOPTDATA(3)