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 to
17       less than a few minutes risk aborting perfectly normal operations. This
18       option  may  cause  libcurl to use the SIGALRM signal to timeout system
19       calls.
20
21       In unix-like systems, this might cause signals to be used  unless  CUR‐
22       LOPT_NOSIGNAL(3) is set.
23
24       If both CURLOPT_TIMEOUT(3) and CURLOPT_TIMEOUT_MS(3) are set, the value
25       set last will be used.
26
27       Since this puts a hard limit for how long time a request is allowed  to
28       take,  it  has  limited  use in dynamic use cases with varying transfer
29       times. You are then advised to explore CURLOPT_LOW_SPEED_LIMIT(3), CUR‐
30       LOPT_LOW_SPEED_TIME(3)  or  using CURLOPT_PROGRESSFUNCTION(3) to imple‐
31       ment your own timeout logic.
32

DEFAULT

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

PROTOCOLS

38       All
39

EXAMPLE

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

AVAILABILITY

52       Always
53

RETURN VALUE

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

SEE ALSO

59       CURLOPT_TIMEOUT_MS(3),         CURLOPT_CONNECTTIMEOUT(3),          CUR‐
60       LOPT_LOW_SPEED_LIMIT(3),
61
62
63
64libcurl 7.61.1                 October 03, 2017             CURLOPT_TIMEOUT(3)
Impressum