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