1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS
5Section: 3
6Source: libcurl
7Protocol:
8  - All
9See-also:
10  - CURLOPT_CONNECTTIMEOUT_MS (3)
11  - CURLOPT_LOW_SPEED_LIMIT (3)
12  - CURLOPT_TIMEOUT (3)
13Added-in: 7.59.0
14---
15
16# NAME
17
18CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS - head start for IPv6 for happy eyeballs
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS,
26                          long timeout);
27~~~
28
29# DESCRIPTION
30
31Happy eyeballs is an algorithm that attempts to connect to both IPv4 and IPv6
32addresses for dual-stack hosts, preferring IPv6 first for *timeout*
33milliseconds. If the IPv6 address cannot be connected to within that time then
34a connection attempt is made to the IPv4 address in parallel. The first
35connection to be established is the one that is used.
36
37The range of suggested useful values for *timeout* is limited. Happy
38Eyeballs RFC 6555 says "It is RECOMMENDED that connection attempts be paced
39150-250 ms apart to balance human factors against network load." libcurl
40currently defaults to 200 ms. Firefox and Chrome currently default to 300 ms.
41
42# DEFAULT
43
44CURL_HET_DEFAULT (currently defined as 200L)
45
46# %PROTOCOLS%
47
48# EXAMPLE
49
50~~~c
51int main(void)
52{
53  CURL *curl = curl_easy_init();
54  if(curl) {
55    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
56    curl_easy_setopt(curl, CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, 300L);
57
58    curl_easy_perform(curl);
59
60    /* always cleanup */
61    curl_easy_cleanup(curl);
62  }
63}
64~~~
65
66# %AVAILABILITY%
67
68# RETURN VALUE
69
70Returns CURLE_OK
71