CURLINFO_CONNECT_TIME.md (1443B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_CONNECT_TIME 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLINFO_CONNECT_TIME_T (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11 Protocol: 12 - All 13 Added-in: 7.4.1 14 --- 15 16 # NAME 17 18 CURLINFO_CONNECT_TIME - get the time until connect 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONNECT_TIME, double *timep); 26 ~~~ 27 28 # DESCRIPTION 29 30 Pass a pointer to a double to receive the total time in seconds from the start 31 until the connection to the remote host (or proxy) was completed. 32 33 When a redirect is followed, the time from each request is added together. 34 35 See also the TIMES overview in the curl_easy_getinfo(3) man page. 36 37 # %PROTOCOLS% 38 39 # EXAMPLE 40 41 ~~~c 42 int 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 66 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 67 68 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 69 libcurl-errors(3).