1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_CONNECT_TIME 5Section: 3 6Source: libcurl 7See-also: 8 - CURLINFO_CONNECT_TIME_T (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11Protocol: 12 - All 13Added-in: 7.4.1 14--- 15 16# NAME 17 18CURLINFO_CONNECT_TIME - get the time until connect 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONNECT_TIME, double *timep); 26~~~ 27 28# DESCRIPTION 29 30Pass a pointer to a double to receive the total time in seconds from the start 31until the connection to the remote host (or proxy) was completed. 32 33When a redirect is followed, the time from each request is added together. 34 35See also the TIMES overview in the curl_easy_getinfo(3) man page. 36 37# %PROTOCOLS% 38 39# EXAMPLE 40 41~~~c 42int main(void) 43{ 44 CURL *curl = curl_easy_init(); 45 if(curl) { 46 CURLcode res; 47 double connect; 48 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 49 res = curl_easy_perform(curl); 50 if(CURLE_OK == res) { 51 res = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &connect); 52 if(CURLE_OK == res) { 53 printf("Time: %.1f", connect); 54 } 55 } 56 /* always cleanup */ 57 curl_easy_cleanup(curl); 58 } 59} 60~~~ 61 62# %AVAILABILITY% 63 64# RETURN VALUE 65 66Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 67