1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLINFO_OS_ERRNO 5Section: 3 6Source: libcurl 7See-also: 8 - curl_easy_getinfo (3) 9 - curl_easy_setopt (3) 10Protocol: 11 - All 12Added-in: 7.12.2 13--- 14 15# NAME 16 17CURLINFO_OS_ERRNO - get errno number from last connect failure 18 19# SYNOPSIS 20 21~~~c 22#include <curl/curl.h> 23 24CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_OS_ERRNO, long *errnop); 25~~~ 26 27# DESCRIPTION 28 29Pass a pointer to a long to receive the errno variable from a connect failure. 30Note that the value is only set on failure, it is not reset upon a successful 31operation. The number is OS and system specific. 32 33libcurl network-related errors that may have a saved errno are: 34CURLE_COULDNT_CONNECT, CURLE_FAILED_INIT, CURLE_INTERFACE_FAILED, 35CURLE_OPERATION_TIMEDOUT, CURLE_RECV_ERROR, CURLE_SEND_ERROR. 36 37Since 8.8.0 libcurl clears the easy handle's saved errno before performing the 38transfer. Prior versions did not clear the saved errno, which means if a saved 39errno is retrieved it could be from a previous transfer on the same handle. 40 41# %PROTOCOLS% 42 43# EXAMPLE 44 45~~~c 46int main(void) 47{ 48 CURL *curl = curl_easy_init(); 49 if(curl) { 50 CURLcode res; 51 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 52 res = curl_easy_perform(curl); 53 if(res != CURLE_OK) { 54 long error; 55 res = curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &error); 56 if(!res && error) { 57 printf("Errno: %ld\n", error); 58 } 59 } 60 curl_easy_cleanup(curl); 61 } 62} 63~~~ 64 65# %AVAILABILITY% 66 67# RETURN VALUE 68 69Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. 70