GNURLMOPT_SOCKETDATA(3)
π GNURLMOPT_SOCKETDATA(3) π
okay so bestie, this is a page from the curl_multi_setopt options section of the gnurl manual, and itβs lowkey iconic because itβs all about the custom pointer you hand to your socket callback. periodt. β¨
πΈ NAME πΈ
CURLMOPT_SOCKETDATAβ custom pointer passed to the socket callback π«Ά
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLMcode curl_multi_setopt(CURLM *handle, CURLMOPT_SOCKETDATA, void *pointer);
π DESCRIPTION π
okay so CURLMOPT_SOCKETDATA is literally the data pointer you pass to the socket callback that you set with the CURLMOPT_SOCKETFUNCTION(3) option. thatβs the whole vibe check. π
libcurl will not touch this pointer β no cap β it will only pass it into the socket callbackβs userp argument. so itβs your cute lilβ custom pointer, and libcurl just carries it over fr fr. π
π DEFAULT π
NULL β yep, the default is just NULL, bestie. π
π¦ PROTOCOLS π¦
All β every protocol, slay. π
π₯ EXAMPLE π₯
the manualβs example is iconic, so here it is exactly:
static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
{
GlobalInfo *g = (GlobalInfo*) cbp;
SockInfo *fdp = (SockInfo*) sockp;
if(what == CURL_POLL_REMOVE) {
remsock(fdp);
}
else {
if(!fdp) {
addsock(s, e, what, g);
}
else {
setsock(fdp, s, e, what, g);
}
}
return 0;
}
main()
{
GlobalInfo setup;
/* ... use socket callback and custom pointer */
curl_multi_setopt(multi, CURLMOPT_SOCKETFUNCTION, sock_cb);
curl_multi_setopt(multi, CURLMOPT_SOCKETDATA, &setup);
}
β AVAILABILITY β
Added in 7.15.4 β so this one has been around for a minute. π
π RETURN VALUE π
Returns CURLM_OK. thatβs it, thatβs the return value. π
π SEE ALSO π
okay bye bestie π this page is from libcurl 7.39.0 and dated 3 Nov 2014 β periodt, 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