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:numpis along *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
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms