1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_NUM_CONNECTS 5Section: 3 6Source: libcurl 7See-also: 8 - curl_easy_getinfo (3) 9 - curl_easy_setopt (3) 10--- 11 12# NAME 13 14CURLINFO_NUM_CONNECTS - get number of created connections 15 16# SYNOPSIS 17 18~~~c 19#include <curl/curl.h> 20 21CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_NUM_CONNECTS, long *nump); 22~~~ 23 24# DESCRIPTION 25 26Pass a pointer to a long to receive how many new connections libcurl had to 27create to achieve the previous transfer (only the successful connects are 28counted). Combined with CURLINFO_REDIRECT_COUNT(3) you are able to know how 29many times libcurl successfully reused existing connection(s) or not. See the 30connection options of curl_easy_setopt(3) to see how libcurl tries to make 31persistent connections to save time. 32 33# PROTOCOLS 34 35All 36 37# EXAMPLE 38 39~~~c 40int main(void) 41{ 42 CURL *curl = curl_easy_init(); 43 if(curl) { 44 CURLcode res; 45 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 46 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 47 res = curl_easy_perform(curl); 48 if(res == CURLE_OK) { 49 long connects; 50 res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &connects); 51 if(res) 52 printf("It needed %ld connects\n", connects); 53 } 54 curl_easy_cleanup(curl); 55 } 56} 57~~~ 58 59# AVAILABILITY 60 61Added in 7.12.3 62 63# RETURN VALUE 64 65Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 66