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