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