GNURLINFO...OOKUP_TIME(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

πŸ’… GNURLINFO...OOKUP_TIME(3) β€” the manual page formerly known as CURLINFO_NAMELOOKUP_TIME

okay so bestie, this one lives in the curl_easy_getinfo options section of the manual (that's the manual name, and yes it's a whole vibe), and it's all about finding out how long the DNS name lookup took. literally just that. iconic.


✨ NAME ✨

CURLINFO_NAMELOOKUP_TIME β€” get the name lookup time πŸ•


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gnurl/curl.h>

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

🌸 DESCRIPTION 🌸

So here's the tea πŸ“: you pass in a pointer to a double, and it gets filled with the total time in seconds from the start of everything until the name resolving was completed. that's it, that's the whole thing.

when a redirect is followed, the time from each request gets added together β€” so you're getting the sum, not just the last hop. no cap. πŸ‘‘

also, go peek at the TIMES overview in the curl_easy_getinfo(3) man page, iykyk. ✨


🌈 PROTOCOLS 🌈

All β€” every single one, we love an inclusive queen πŸ’–


πŸŽ€ EXAMPLE πŸŽ€

curl = curl_easy_init();
if(curl) {
  double namelookup;
  curl_easy_setopt(curl, CURLOPT_URL, url);
  res = curl_easy_perform(curl);
  if(CURLE_OK == res) {
    res = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &namelookup);
    if(CURLE_OK == res) {
      printf("Time: %.1f", namelookup);
    }
  }
  /* always cleanup */
  curl_easy_cleanup(curl);
}

look at that. clean. slay. don't forget the cleanup at the end, bestie, that's the /* always cleanup */ energy we respect. 🫢


⭐ AVAILABILITY ⭐

Added in 7.4.1 β€” she's been around a minute, an elder icon πŸ’…


πŸ”₯ RETURN VALUE πŸ”₯

  • Returns CURLE_OK if the option is supported πŸ’š
  • Returns CURLE_UNKNOWN_OPTION if it's not πŸ’€

that's the whole vibe check, fr fr.


πŸ‘‘ SEE ALSO πŸ‘‘

go read those too, they're all linked in the group chat 🧚


mwah πŸ’‹ this page was brought to you by libcurl 7.44.0, dated 28 Aug 2015 β€” a vintage moment, and the header says GNURLINFO...OOKUP_TIME(3) if you were wondering where we came from. bye bestie, go measure some lookup times πŸ¦‹βœ¨

πŸ“¦ where this page comes from