1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_CONNECTTIMEOUT_MS 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_LOW_SPEED_LIMIT (3) 9 - CURLOPT_MAX_RECV_SPEED_LARGE (3) 10 - CURLOPT_TIMEOUT_MS (3) 11Protocol: 12 - All 13Added-in: 7.16.2 14--- 15 16# NAME 17 18CURLOPT_CONNECTTIMEOUT_MS - timeout for the connect phase 19 20# SYNOPSIS 21 22~~~c 23#include <curl/curl.h> 24 25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECTTIMEOUT_MS, 26 long timeout); 27~~~ 28 29# DESCRIPTION 30 31Pass a long. It sets the maximum time in milliseconds that you allow the 32connection phase to take. This timeout only limits the connection phase, it 33has no impact once libcurl has connected. The connection phase includes the 34name resolve (DNS) and all protocol handshakes and negotiations until there is 35an established connection with the remote side. 36 37Set this option to zero to switch to the default built-in connection timeout - 38300 seconds. See also the CURLOPT_TIMEOUT_MS(3) option. 39 40CURLOPT_CONNECTTIMEOUT(3) is the same function but set in seconds. 41 42If both CURLOPT_CONNECTTIMEOUT(3) and CURLOPT_CONNECTTIMEOUT_MS(3) are set, 43the value set last is used. 44 45The connection timeout is included in the general all-covering 46CURLOPT_TIMEOUT_MS(3): 47 48With CURLOPT_CONNECTTIMEOUT_MS(3) set to 3000 and CURLOPT_TIMEOUT_MS(3) set to 495000, the operation can never last longer than 5000 milliseconds, and the 50connection phase cannot last longer than 3000 milliseconds. 51 52With CURLOPT_CONNECTTIMEOUT_MS(3) set to 4000 and CURLOPT_TIMEOUT_MS(3) set to 532000, the operation can never last longer than 2000 milliseconds. Including 54the connection phase. 55 56This option may cause libcurl to use the SIGALRM signal to timeout system 57calls on builds not using asynch DNS. In Unix-like systems, this might cause 58signals to be used unless CURLOPT_NOSIGNAL(3) is set. 59 60# DEFAULT 61 62300000 63 64# %PROTOCOLS% 65 66# EXAMPLE 67 68~~~c 69int main(void) 70{ 71 CURL *curl = curl_easy_init(); 72 if(curl) { 73 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 74 75 /* complete connection within 10000 milliseconds */ 76 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 10000L); 77 78 curl_easy_perform(curl); 79 } 80} 81~~~ 82 83# %AVAILABILITY% 84 85# RETURN VALUE 86 87Returns CURLE_OK 88