CURLINFO_NAMELOOKUP_TIME(3)

CURLINFO_NAMELOOKUP_TIME(3) πŸ’…

okay so bestie, welcome to the libcurl Library Functions Manual corner of the group chat 🫢 we're talking about CURLINFO_NAMELOOKUP_TIME, and it's giving β€œhow long did the name lookup take” energy.

🌸 NAME 🌸

CURLINFO_NAMELOOKUP_TIME β€” name lookup time. no cap, that's the whole vibe.

✨ SYNOPSIS ✨

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NAMELOOKUP_TIME,
                           double *timep);

πŸ’– DESCRIPTION πŸ’–

You pass a pointer to a double, and it gets the total time in seconds from the start until the name resolving was completed. yes bestie, seconds, and it's a double, so cute and precise.

When a redirect is followed, the time from each request is added together. so redirects stack their times, fr fr.

Also go peek at the TIMES overview in the curl_easy_getinfo(3) man page β€” it's the bigger picture, iykyk.

πŸ¦‹ PROTOCOLS πŸ¦‹

This functionality affects all supported protocols πŸ’… like, every supported protocol gets this energy.

πŸŽ€ EXAMPLE πŸŽ€

here's the whole little C moment, copied exactly because we do not mess with code:

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    double namelookup;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
    result = curl_easy_perform(curl);
    if(CURLE_OK == result) {
      result = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &namelookup);
      if(CURLE_OK == result) {
        printf("Time: %.1f", namelookup);
      }
    }
    /* always cleanup */
    curl_easy_cleanup(curl);
  }
}

🌈 AVAILABILITY 🌈

Added in curl 7.4.1 β€” iconic vintage behavior, but make it current. ✨

πŸ‘‘ RETURN VALUE πŸ‘‘

curl_easy_getinfo(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) if things get messy πŸ’€.

🫢 SEE ALSO 🫢


that's the page, bestie: brought to you by libcurl, dated 2026-10-12, and filed under CURLINFO_NAMELOOKUP_TIME(3) πŸŽ€βœ¨

πŸ“¦ where this page comes from