1CURLINFO_NUM_CONNECTS(3)   curl_easy_getinfo options  CURLINFO_NUM_CONNECTS(3)
2
3
4

NAME

6       CURLINFO_NUM_CONNECTS - get number of created connections
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode  curl_easy_getinfo(CURL  *handle,  CURLINFO_NUM_CONNECTS, long
12       *nump);
13

DESCRIPTION

15       Pass a pointer to a long to receive how many  new  connections  libcurl
16       had  to  create  to  achieve the previous transfer (only the successful
17       connects are counted).  Combined  with  CURLINFO_REDIRECT_COUNT(3)  you
18       are  able  to  know how many times libcurl successfully reused existing
19       connection(s) or not.  See  the  connection  options  of  curl_easy_se‐
20       topt(3) to see how libcurl tries to make persistent connections to save
21       time.
22

PROTOCOLS

24       All
25

EXAMPLE

27       CURL *curl = curl_easy_init();
28       if(curl) {
29         CURLcode res;
30         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
31         curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
32         res = curl_easy_perform(curl);
33         if(res == CURLE_OK) {
34           long connects;
35           res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connects);
36           if(res)
37             printf("It needed %d connects\n", connects);
38         }
39         curl_easy_cleanup(curl);
40       }
41

AVAILABILITY

43       Added in 7.12.3
44

RETURN VALUE

46       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
47       if not.
48

SEE ALSO

50       curl_easy_getinfo(3), curl_easy_setopt(3),
51
52
53
54libcurl 7.76.1                 November 04, 2020      CURLINFO_NUM_CONNECTS(3)
Impressum