GNURLINFO_OS_ERRNO(3)
π
GNURLINFO_OS_ERRNO(3) β like, the curl_easy_getinfo options era π
okay bestie, so this one lives in the curl_easy_getinfo options family (that's the manual name, iykyk) and it's literally about catching the errno from a failed connect. let's get into it β¨
πΈ NAME πΈ
CURLINFO_OS_ERRNO β grab the errno number from the last connect failure π«Ά
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_OS_ERRNO, long *errnop);
like, that's the whole vibe. you hand it a long pointer and it fills it in π
π DESCRIPTION π
so here's the tea: you pass a pointer to a long, and it receives the errno variable from a connect failure. that's it, that's the whole thing π
β οΈ important caveat, no cap: the value is only set on failure. it is not reset when an operation succeeds. so if you're out here reading it after a win, you're reading stale vibes, bestie π
also highkey relevant: the number is OS and system specific. so like, don't go comparing it across machines expecting matching energy π
π¦ PROTOCOLS π¦
All π
π EXAMPLE π
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
res = curl_easy_perform(curl);
if(res != CURLE_OK) {
long error;
res = curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &error);
if(res && error) {
printf("Errno: %ld\n", error);
}
}
curl_easy_cleanup(curl);
}
look at that little if(res && error) check doing its main character thing π₯
β AVAILABILITY β
added in 7.12.2 β vintage but iconic, fr fr π
π RETURN VALUE π
- returns
CURLE_OKif the option is supported β - returns
CURLE_UNKNOWN_OPTIONif it's not π
that's the whole vibe check.
π SEE ALSO π
okay that's the page!! mwah π this was libcurl 7.44.0, dated 1 Sep 2015, and yes she's giving GNURLINFO_OS_ERRNO(3) energy the whole way through β go forth and debug your connects, bestie π§ββοΈπ
π¦ 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