1CURLOPT_CONNECTTIMEOUT(3)  curl_easy_setopt options  CURLOPT_CONNECTTIMEOUT(3)
2
3
4

NAME

6       CURLOPT_CONNECTTIMEOUT - timeout for the connect phase
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECTTIMEOUT, long timeout);
12

DESCRIPTION

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

DEFAULT

27       300
28

PROTOCOLS

30       All
31

EXAMPLE

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

AVAILABILITY

44       Always
45

RETURN VALUE

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

SEE ALSO

51       CURLOPT_CONNECTTIMEOUT_MS(3),         CURLOPT_TIMEOUT(3),          CUR‐
52       LOPT_LOW_SPEED_LIMIT(3),
53
54
55
56libcurl 7.85.0                   May 17, 2022        CURLOPT_CONNECTTIMEOUT(3)
Impressum