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

NAME

6       CURLINFO_PRIMARY_IP - get IP address of last connection
7

SYNOPSIS

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

DESCRIPTION

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

PROTOCOLS

27       All network based ones
28

EXAMPLE

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

AVAILABILITY

48       Added in 7.19.0
49

RETURN VALUE

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

SEE ALSO

55       curl_easy_getinfo(3),  curl_easy_setopt(3),   CURLINFO_PRIMARY_PORT(3),
56       CURLINFO_LOCAL_IP(3),
57
58
59
60libcurl 7.71.1                   June 25, 2020          CURLINFO_PRIMARY_IP(3)
Impressum