CURLINFO_CONNECT_TIME(3)

πŸ’… CURLINFO_CONNECT_TIME(3) β€” time to connect ✨

okay bestie, so this is a libcurl manual page (Library Functions Manual, iykyk) and it's literally all about finding out how long the connect took. buckle up πŸŽ€


🌸 NAME 🌸

CURLINFO_CONNECT_TIME β€” time to connect, periodt πŸ’–


✨ SYNOPSIS ✨

#include <curl/curl.h>

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

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here's the vibe: you pass a pointer to a double, and curl fills it with the total time in seconds from the start until the connection to the remote host (or proxy, no cap) was completed. β±οΈπŸ’…

And when a redirect is followed? The time from each request gets added together. all of them. stacked. the whole journey πŸ”₯

πŸ‘‘ also pls go look at the TIMES overview in the curl_easy_getinfo(3) man page, it's giving main character energy and it's lowkey essential reading 🫢

🌈 PROTOCOLS 🌈

This functionality affects all supported protocols ✨ (yes, all of them, we love range πŸ’–)


πŸ“ EXAMPLE πŸ“

here's the whole thing, character for character, go off bestie:

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

🧚 AVAILABILITY 🧚

Added in curl 7.4.1 β€” a certified classic, we stan a veteran πŸ“…πŸ’œ


⭐ RETURN VALUE ⭐

curl_easy_getinfo(3) returns a CURLcode indicating success or error, that's the whole deal πŸ’€

  • CURLE_OK (0) means everything was OK πŸŽ‰ slay
  • non-zero means an error occurred 😭 see libcurl-errors(3) for the full breakdown

πŸ’œ SEE ALSO πŸ’œ


πŸ’– and that's the page!! brought to you by libcurl, dated 2026-10-12 β€” go time your connects bestie, mwah πŸ’‹πŸŒ·

πŸ“¦ where this page comes from