1CURLINFO_LOCAL_IP(3)       curl_easy_getinfo options      CURLINFO_LOCAL_IP(3)
2
3
4

NAME

6       CURLINFO_LOCAL_IP - get local IP address of last connection
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LOCAL_IP, char **ip);
12

DESCRIPTION

14       Pass  a pointer to a char pointer to receive the pointer to a zero-ter‐
15       minated string holding the IP address of the local end of  most  recent
16       connection  done  with  this  curl handle. This string may be IPv6 when
17       that is enabled. Note that you get a pointer to a memory area that will
18       be  re-used  at next request so you need to copy the string if you want
19       to keep the information.
20
21       The ip pointer will be NULL or pointing to private memory you MUST  NOT
22       free  -  it gets freed when you call curl_easy_cleanup(3) on the corre‐
23       sponding CURL handle.
24

PROTOCOLS

26       All
27

EXAMPLE

29       {
30         char *ip;
31
32         curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
33
34         /* Perform the request, res will get the return code */
35         res = curl_easy_perform(curl);
36         /* Check for errors */
37         if((res == CURLE_OK) &&
38            !curl_easy_getinfo(curl, CURLINFO_LOCAL_IP, &ip) && ip) {
39           printf("Local IP: %s\n", ip);
40         }
41
42         /* always cleanup */
43         curl_easy_cleanup(curl);
44       }
45

AVAILABILITY

47       Added in 7.21.0
48

RETURN VALUE

50       Returns CURLE_OK if the option is supported,  and  CURLE_UNKNOWN_OPTION
51       if not.
52

SEE ALSO

54       curl_easy_getinfo(3), curl_easy_setopt(3), CURLINFO_PRIMARY_IP(3),
55
56
57
58libcurl 7.69.1                   May 05, 2017             CURLINFO_LOCAL_IP(3)
Impressum