GNURLOPT_SOCKOPTDATA(3)
π NAME π
okay bestie, welcome to the GNURLOPT_SOCKOPTDATA(3) page from the curl_easy_setopt options manual. This one is about CURLOPT_SOCKOPTDATA β custom pointer to pass to sockopt callback. That's the whole name, periodt. π
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_SOCKOPTDATA, void
*pointer);
π¦ DESCRIPTION π¦
So you pass a pointer, right? libcurl is gonna leave that pointer completely untouched β hands off, no cap β and it gets passed as the first argument in the sockopt callback that you set with CURLOPT_SOCKOPTFUNCTION(3). That's it. That's the vibe. π«Ά
π DEFAULT π
The default value of this parameter is NULL. So if you don't set it, it's just null, bestie. π
π PROTOCOLS π
All β every single protocol. no cap. β¨
π₯ EXAMPLE π₯
okay here's the cute lil' code moment:
static int sockopt_callback(void *clientp, curl_socket_t curlfd,
curlsocktype purpose)
{
int val = *(int *)clientp;
setsockopt(curldfd, SOL_SOCKET, SO_RCVBUF, (const char *)&val, sizeof(val));
return CURL_SOCKOPT_OK;
}
curl = curl_easy_init();
if(curl) {
int recvbuffersize = 256 * 1024;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/");
/* call this function to set options for the socket */
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
curl_easy_setopt(curl, CURLOPT_SOCKOPTDATA, &recvbuffersize);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
π AVAILABILITY π
Added in 7.16.0. iconic. π
β RETURN VALUE β
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. Lowkey simple. π
πΈ SEE ALSO πΈ
xoxo, ur Unix bestie π β this page is from libcurl 7.37.0, dated 16 Jun 2014, and it's the GNURLOPT_SOCKOPTDATA(3) manual page. mwah π
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms