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