1CURLOPT_CONNECTTIMEOUT(3) libcurl 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
26 The "connection phase" is considered complete when the requested TCP,
27 TLS or QUIC handshakes are done.
28
30 300
31
33 All
34
36 CURL *curl = curl_easy_init();
37 if(curl) {
38 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
39
40 /* complete connection within 10 seconds */
41 curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L);
42
43 curl_easy_perform(curl);
44 }
45
47 Always
48
50 Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a nega‐
51 tive value or a value that when converted to milliseconds is too large.
52
54 CURLOPT_CONNECTTIMEOUT_MS(3), CURLOPT_TIMEOUT(3), CUR‐
55 LOPT_LOW_SPEED_LIMIT(3),
56
57
58
59ibcurl 8.2.1 April 26, 2023 CURLOPT_CONNECTTIMEOUT(3)