GNURLOPT_TIMEOUT_MS(3)
π GNURLOPT_TIMEOUT_MS β setting the maximum time your request can take β¨
Okay bestie, so like, this page is for GNURLOPT_TIMEOUT_MS in section 3 of the manual, and it's all about putting a hard time limit on your libcurl transfer. Let's get into it π«Ά
πΈ NAME πΈ
CURLOPT_TIMEOUT_MS β set maximum time the request is allowed to take π
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TIMEOUT_MS, long
timeout);
π¦ DESCRIPTION π¦
So you pass a long as the parameter, and that's your timeout β the maximum time in milliseconds that you're allowing the libcurl transfer operation to take. Literally the whole vibe is "this request better wrap up in this many ms or we're out" π
Ngl, normally name lookups can take a considerable time, and limiting operations to less than a few minutes risks aborting perfectly normal operations. Like, give it some room to breathe, okay? π This option may cause libcurl to use the SIGALRM signal to timeout system calls.
If libcurl is built to use the standard system name resolver, that portion of the transfer will still use full-second resolution for timeouts with a minimum timeout allowed of one second. So like, keep that in mind bestie π
Important vibe check: In unix-like systems, this might cause signals to be used unless CURLOPT_NOSIGNAL(3) is set. So if you're not about that signal life, set that option fr fr π
If both CURLOPT_TIMEOUT(3) and CURLOPT_TIMEOUT_MS(3) are set, the value set last will be used. Like, last one in wins, periodt π
Since this puts a hard limit for how long time a request is allowed to take, it has limited use in dynamic use cases with varying transfer times. You are then advised to explore CURLOPT_LOW_SPEED_LIMIT(3), CURLOPT_LOW_SPEED_TIME(3) or using CURLOPT_PROGRESSFUNCTION(3) to implement your own timeout logic. That's the move when you need more flexibility, iykyk π
π DEFAULT π
Default timeout is 0 (zero) which means it never times out during transfer. So like, the default is literally no limit β main character energy that just goes and goes π
π₯ PROTOCOLS π₯
All β¨
β EXAMPLE β
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* complete within 20000 milliseconds */
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 20000L);
curl_easy_perform(curl);
}
π§ AVAILABILITY π§
Always π
π RETURN VALUE π
Returns CURLE_OK β that's the good one, slay π
πΈ SEE ALSO πΈ
π That's the whole page bestie! This icon of a manpage is brought to you by libcurl 7.37.0, dated 17 Jun 2014. She's serving vintage but she's still iconic, no cap π«Άβ¨
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms