GNURLOPT_CONNECTTIMEOUT(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

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