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