GNURLINFO_NUM_CONNECTS(3)

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

🌸 NAME 🌸

Hey bestie πŸ’– this is GNURLINFO_NUM_CONNECTS(3), straight from the curl_easy_getinfo options manual β€” and it's all about get number of created connections ✨


✨ SYNOPSIS ✨

#include <gnurl/curl.h>

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

πŸ’… DESCRIPTION πŸ’…

Okay so you pass in a pointer to a long, and it receives how many brand-new connections libcurl had to create to pull off the previous transfer β€” and no cap, only the successful connects are counted πŸ’–

Team it up with CURLINFO_REDIRECT_COUNT(3) and you can figure out how many times libcurl successfully reused existing connection(s) or didn't πŸ‘‘ Check the connection options in curl_easy_setopt(3) to see how libcurl tries to make persistent connections and save time β€” iconic behavior, honestly ⭐

bestie, the β€œonly successful connects” thing is the whole vibe check here πŸ’…

🌈 PROTOCOLS 🌈

All β€” every protocol, periodt 🌈


πŸŽ€ EXAMPLE πŸŽ€

Here's the exact example, untouched and serving main-character energy:

       CURL *curl = curl_easy_init();
       if(curl) {
         CURLcode res;
         curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
         curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
         res = curl_easy_perform(curl);
         if(res == CURLE_OK) {
           long connects;
           res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connects);
           if(res)
             printf("It needed %d connects\n", connects);
         }
         curl_easy_cleanup(curl);
       }

πŸ¦‹ AVAILABILITY πŸ¦‹

Added in 7.12.3 β€” vintage but still iconic πŸŽ€


πŸ”₯ RETURN VALUE πŸ”₯

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. Simple as that, bestie πŸ’œ


🫢 SEE ALSO 🫢

curl_easy_getinfo(3), curl_easy_setopt(3), β€” go read those too, iykyk πŸ‘‘


Signed off with libcurl 7.44.0 energy, dated 12 Sep 2015 β€” mwah πŸ’‹

πŸ“¦ where this page comes from