1CURLOPT_CONNECTTIMEOUT(3) curl_easy_setopt options CURLOPT_CONNECTTIMEOUT(3)
2
3
4
6 CURLOPT_CONNECTTIMEOUT - timeout for the connect phase
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECTTIMEOUT, long timeout);
12
14 Pass a long. It should contain the maximum time in seconds that you al‐
15 low the connection phase to the server to take. This only limits the
16 connection phase, it has no impact once it has connected. Set to zero
17 to switch to the default built-in connection timeout - 300 seconds. See
18 also the CURLOPT_TIMEOUT(3) option.
19
20 In unix-like systems, this might cause signals to be used unless CUR‐
21 LOPT_NOSIGNAL(3) is set.
22
23 If both CURLOPT_CONNECTTIMEOUT(3) and CURLOPT_CONNECTTIMEOUT_MS(3) are
24 set, the value set last will be used.
25
27 300
28
30 All
31
33 CURL *curl = curl_easy_init();
34 if(curl) {
35 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
36
37 /* complete connection within 10 seconds */
38 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L);
39
40 curl_easy_perform(curl);
41 }
42
44 Always
45
47 Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a nega‐
48 tive value or a value that when converted to milliseconds is too large.
49
51 CURLOPT_CONNECTTIMEOUT_MS(3), CURLOPT_TIMEOUT(3), CUR‐
52 LOPT_LOW_SPEED_LIMIT(3),
53
54
55
56libcurl 7.82.0 November 26, 2021 CURLOPT_CONNECTTIMEOUT(3)