CURLOPT_TIMEOUT_MS.md (1270B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_TIMEOUT_MS 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLOPT_CONNECTTIMEOUT (3) 9 - CURLOPT_LOW_SPEED_LIMIT (3) 10 - CURLOPT_TCP_KEEPALIVE (3) 11 - CURLOPT_TIMEOUT (3) 12 Protocol: 13 - All 14 Added-in: 7.16.2 15 --- 16 17 # NAME 18 19 CURLOPT_TIMEOUT_MS - maximum time the transfer is allowed to complete 20 21 # SYNOPSIS 22 23 ~~~c 24 #include <curl/curl.h> 25 26 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEOUT_MS, long timeout); 27 ~~~ 28 29 # DESCRIPTION 30 31 Pass a long as parameter containing *timeout* - the maximum time in 32 milliseconds that you allow the libcurl transfer operation to take. 33 34 See CURLOPT_TIMEOUT(3) for details. 35 36 # DEFAULT 37 38 0 (zero) which means it never times out during transfer. 39 40 # %PROTOCOLS% 41 42 # EXAMPLE 43 44 ~~~c 45 int main(void) 46 { 47 CURL *curl = curl_easy_init(); 48 if(curl) { 49 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 50 51 /* complete within 20000 milliseconds */ 52 curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 20000L); 53 54 curl_easy_perform(curl); 55 } 56 } 57 ~~~ 58 59 # %AVAILABILITY% 60 61 # RETURN VALUE 62 63 curl_easy_setopt(3) returns a CURLcode indicating success or error. 64 65 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 66 libcurl-errors(3).