GNURLOPT_CONNECTTIMEOUT(3)
okay so bestie, welcome to GNURLOPT_CONNECTTIMEOUT(3) from the curl_easy_setopt options manual π we're talking about CURLOPT_CONNECTTIMEOUT, aka the βhow long do I wait for this connection, omgβ knob, and it's lowkey iconic β¨
πΈ NAME πΈ
CURLOPT_CONNECTTIMEOUT β timeout for the connect phase. That's the name, that's the vibe, periodt π
π¦ SYNOPSIS π¦
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CONNECTTIMEOUT, long
timeout);
π DESCRIPTION π
Pass a long. That long should contain the maximum time in seconds that you allow the connection phase to the server to take. This only limits the connection phase β once it has connected, it has no impact. No cap. β³
Set it to zero to switch to the default built-in connection timeout β 300 seconds. Also see the CURLOPT_TIMEOUT(3) option if you're doing timeout lore π
π¨ caveat, bestie: in unix-like systems, this might cause signals to be used unless CURLOPT_NOSIGNAL(3) is set.
If both CURLOPT_CONNECTTIMEOUT(3) and CURLOPT_CONNECTTIMEOUT_MS(3) are set, the value set last will be used. Last one wins, fr fr π
π DEFAULT π
300 β literally 300 seconds, the built-in default π
π PROTOCOLS π
All β all the protocols, no gatekeeping π«
β¨ EXAMPLE β¨
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
/* complete connection within 10 seconds */
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 10L);
curl_easy_perform(curl);
}
π₯ AVAILABILITY π₯
Always. Like, always always. π
π RETURN VALUE π
Returns CURLE_OK. Returns CURLE_BAD_FUNCTION_ARGUMENT if set to a negative value or a value that when converted to milliseconds is too large. So don't set it to a negative gremlin number, mwah π
π§ SEE ALSO π§
source/version: libcurl 7.37.0 Β· date: 17 Jun 2014 Β· page: GNURLOPT_CONNECTTIMEOUT(3) β folded into this cute lil sign-off instead of a boring footer π«Ά bye bestie, go set your timeouts responsibly ππ¦
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, 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