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