CURLINFO_NUM_CONNECTS(3)

πŸ’… CURLINFO_NUM_CONNECTS πŸ’…

okay bestie, so this is the libcurl library functions manual page for CURLINFO_NUM_CONNECTS β€” yes it's a whole mouthful but i promise it slaps, just stay with me 🫢


✨ NAME ✨

CURLINFO_NUM_CONNECTS β€” literally just the number of connections libcurl created, no cap


🌸 SYNOPSIS 🌸

#include <curl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NUM_CONNECTS, long *nump);

πŸ’– DESCRIPTION πŸ’–

so basically, you pass a pointer to a long (nump, hi bestie πŸ‘‹) and it comes back holding how many new connections libcurl had to create to pull off the previous transfer. and bestie, only the successful connects get counted β€” we don't count flops here πŸ’…

the iconic play: pair it with CURLINFO_REDIRECT_COUNT(3) and you can lowkey figure out exactly how many times libcurl successfully reused existing connection(s) or... didn't πŸ™ˆ that's the vibe check on your connection reuse fr fr.

and if you wanna know how libcurl tries to make persistent connections to save time (it's giving efficiency queen), go peek at the connection options of curl_easy_setopt(3) ✨


πŸ¦‹ PROTOCOLS πŸ¦‹

this functionality affects all supported protocols β€” every single one, we're inclusive over here 🌈


πŸŽ€ EXAMPLE πŸŽ€

int main(void)
{
  CURL *curl = curl_easy_init();
  if(curl) {
    CURLcode result;
    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
    result = curl_easy_perform(curl);
    if(result == CURLE_OK) {
      long connects;
      result = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connects);
      if(!result)
        printf("It needed %ld connects\n", connects);
    }
    curl_easy_cleanup(curl);
  }
}

like, yes bestie, it just tells you how many connects it needed πŸ”₯


⭐ AVAILABILITY ⭐

added in curl 7.12.3 β€” vintage but still iconic, iykyk πŸ‘‘


🧚 RETURN VALUE 🧚

curl_easy_getinfo(3) returns a CURLcode indicating success or error.

CURLE_OK (0) means everything was OK πŸŽ‰ β€” and non-zero means an error occurred, so go check libcurl-errors(3) for the tea πŸ’€


πŸ‘‘ SEE ALSO πŸ‘‘


bestie please remember: nump is a long * and you actually have to pass a real pointer, we're not doing undefined behavior today 😭

okay that's the whole page, love u, go count your connects πŸ’œ this was libcurl, dated 2026-10-12, from the CURLINFO_NUM_CONNECTS(3) era β€” slay and goodnight βœ¨πŸ’…πŸ«Ά

πŸ“¦ where this page comes from