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 *nump);
12

DESCRIPTION

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

PROTOCOLS

23       All
24

EXAMPLE

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

AVAILABILITY

42       Added in 7.12.3
43

RETURN VALUE

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

SEE ALSO

49       curl_easy_getinfo(3), curl_easy_setopt(3),
50
51
52
53libcurl 7.85.0                   May 17, 2022         CURLINFO_NUM_CONNECTS(3)
Impressum