1---
2c: Copyright (C) Daniel Stenberg, <daniel.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)
10---
11
12# NAME
13
14CURLINFO_OS_ERRNO - get errno number from last connect failure
15
16# SYNOPSIS
17
18~~~c
19#include <curl/curl.h>
20
21CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_OS_ERRNO, long *errnop);
22~~~
23
24# DESCRIPTION
25
26Pass a pointer to a long to receive the errno variable from a connect failure.
27Note that the value is only set on failure, it is not reset upon a successful
28operation. The number is OS and system specific.
29
30# PROTOCOLS
31
32All
33
34# EXAMPLE
35
36~~~c
37int main(void)
38{
39  CURL *curl = curl_easy_init();
40  if(curl) {
41    CURLcode res;
42    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
43    res = curl_easy_perform(curl);
44    if(res != CURLE_OK) {
45      long error;
46      res = curl_easy_getinfo(curl, CURLINFO_OS_ERRNO, &error);
47      if(res && error) {
48        printf("Errno: %ld\n", error);
49      }
50    }
51    curl_easy_cleanup(curl);
52  }
53}
54~~~
55
56# AVAILABILITY
57
58Added in 7.12.2
59
60# RETURN VALUE
61
62Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
63