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