CURLOPT_RESOLVER_START_FUNCTION(3)
π CURLOPT_RESOLVER_START_FUNCTION(3) β bestie manual page π
okay so this little icon is from the Library Functions Manual, and itβs all about CURLOPT_RESOLVER_START_FUNCTION β the callback that gets called before a fresh name resolve starts. no cap, itβs a niche but powerful vibe. π¦
β¨ NAME β¨
CURLOPT_RESOLVER_START_FUNCTION β the callback called before a new name resolve is started. literally the βhey bestie, weβre about to resolve a nameβ heads-up. π
πΈ SYNOPSIS πΈ
hereβs the exact summoning circle, copy it carefully bestie:
#include <curl/curl.h>
int resolver_start_cb(void *resolver_state, void *reserved, void *userdata);
CURLcode curl_easy_setopt(CURL *handle,
CURLOPT_RESOLVER_START_FUNCTION,
resolver_start_cb);
π DESCRIPTION π
okay so you pass a pointer to your callback function, and that callback has to match the prototype shown above. libcurl calls it every single time before a new resolve request is started. periodt. π₯
resolver_state points to a backend-specific resolver state. RN only the ares resolver backend has a resolver state. it can be used to set up any desired option on the ares channel before it is used β for example setting up socket callback options. iykyk. π§
reserved is reserved. literally just reserved, bestie, leave it alone. π
userdata is the user pointer set with the CURLOPT_RESOLVER_START_DATA(3) option. thatβs the little thread that ties your stuff together. π«Ά
the callback must return 0 on success. returning a non-zero value causes the resolve to fail β so yeah, donβt do that unless you mean it. π
π DEFAULT π
NULL (No callback) β if you donβt set one, thereβs no callback. simple as that. π
π PROTOCOLS π
This functionality affects all supported protocols. all of them, slay. π
β EXAMPLE β
hereβs the example code, verbatim, because we do not mess with code in this house:
static int start_cb(void *resolver_state, void *reserved,
void *userdata)
{
(void)reserved;
printf("Received resolver_state=%p userdata=%p\n",
resolver_state, userdata);
return 0;
}
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_RESOLVER_START_FUNCTION, start_cb);
curl_easy_setopt(curl, CURLOPT_RESOLVER_START_DATA, curl);
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
π¦ AVAILABILITY π¦
Added in curl 7.59.0. vintage but still iconic. π
π RETURN VALUE π
curl_easy_setopt(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK, non-zero means an error occurred, see libcurl-errors(3). no mystery energy. πΈ
π SEE ALSO π
mwah π β source/version: libcurl, date: 2026-10-12, and the footer tag is CURLOPT_RE...RT_FUNCTION(3). thatβs the whole page, bestie, we out π
β¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms