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

NAME

6       CURLOPT_TIMEOUT - set maximum time the request is allowed to take
7

SYNOPSIS

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

DESCRIPTION

14       Pass  a long as parameter containing timeout - the maximum time in sec‐
15       onds that you allow the libcurl transfer operation to  take.  Normally,
16       name  lookups can take a considerable time and limiting operations risk
17       aborting perfectly normal operations. This option may cause libcurl  to
18       use the SIGALRM signal to timeout system calls.
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_TIMEOUT(3) and CURLOPT_TIMEOUT_MS(3) are set, the value
24       set last will be used.
25
26       Since  this  option  puts  a  hard  limit on how long time a request is
27       allowed to take, it has limited use in dynamic use cases  with  varying
28       transfer times. That is especially apparent when using the multi inter‐
29       face, which may queue the transfer, and that time is included. You  are
30       advised      to      explore      CURLOPT_LOW_SPEED_LIMIT(3),      CUR‐
31       LOPT_LOW_SPEED_TIME(3) or using CURLOPT_PROGRESSFUNCTION(3)  to  imple‐
32       ment your own timeout logic.
33

DEFAULT

35       Default  timeout  is  0  (zero)  which  means it never times out during
36       transfer.
37

PROTOCOLS

39       All
40

EXAMPLE

42       CURL *curl = curl_easy_init();
43       if(curl) {
44         curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
45
46         /* complete within 20 seconds */
47         curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20L);
48
49         curl_easy_perform(curl);
50       }
51

AVAILABILITY

53       Always
54

RETURN VALUE

56       Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a nega‐
57       tive value or a value that when converted to milliseconds is too large.
58

SEE ALSO

60       CURLOPT_TIMEOUT_MS(3),          CURLOPT_CONNECTTIMEOUT(3),         CUR‐
61       LOPT_LOW_SPEED_LIMIT(3),
62
63
64
65libcurl 7.71.1                 October 15, 2019             CURLOPT_TIMEOUT(3)
Impressum