1CURLOPT_TIMEOUT_MS(3) curl_easy_setopt options CURLOPT_TIMEOUT_MS(3)
2
3
4
6 CURLOPT_TIMEOUT_MS - set maximum time the request is allowed to take
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEOUT_MS, long time‐
12 out);
13
15 Pass a long as parameter containing timeout - the maximum time in mil‐
16 liseconds that you allow the libcurl transfer operation to take. Nor‐
17 mally, name lookups can take a considerable time and limiting opera‐
18 tions to less than a few minutes risk aborting perfectly normal opera‐
19 tions. This option may cause libcurl to use the SIGALRM signal to time‐
20 out system calls.
21
22 If libcurl is built to use the standard system name resolver, that por‐
23 tion of the transfer will still use full-second resolution for timeouts
24 with a minimum timeout allowed of one second.
25
26 In unix-like systems, this might cause signals to be used unless CUR‐
27 LOPT_NOSIGNAL(3) is set.
28
29 If both CURLOPT_TIMEOUT(3) and CURLOPT_TIMEOUT_MS(3) are set, the value
30 set last will be used.
31
32 Since this puts a hard limit for how long time a request is allowed to
33 take, it has limited use in dynamic use cases with varying transfer
34 times. You are then advised to explore CURLOPT_LOW_SPEED_LIMIT(3), CUR‐
35 LOPT_LOW_SPEED_TIME(3) or using CURLOPT_PROGRESSFUNCTION(3) to imple‐
36 ment your own timeout logic.
37
39 Default timeout is 0 (zero) which means it never times out during
40 transfer.
41
43 All
44
46 CURL *curl = curl_easy_init();
47 if(curl) {
48 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
49
50 /* complete within 20000 milliseconds */
51 curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 20000L);
52
53 curl_easy_perform(curl);
54 }
55
57 Always
58
60 Returns CURLE_OK
61
63 CURLOPT_TIMEOUT(3), CURLOPT_CONNECTTIMEOUT(3), CUR‐
64 LOPT_LOW_SPEED_LIMIT(3),
65
66
67
68libcurl 7.76.1 November 04, 2020 CURLOPT_TIMEOUT_MS(3)