quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

CURLINFO_PRIMARY_IP.md (1692B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLINFO_PRIMARY_IP
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLINFO_LOCAL_IP (3)
      9   - CURLINFO_LOCAL_PORT (3)
     10   - CURLINFO_PRIMARY_PORT (3)
     11   - curl_easy_getinfo (3)
     12   - curl_easy_setopt (3)
     13 Protocol:
     14   - All
     15 Added-in: 7.19.0
     16 ---
     17 
     18 # NAME
     19 
     20 CURLINFO_PRIMARY_IP - get IP address of last connection
     21 
     22 # SYNOPSIS
     23 
     24 ~~~c
     25 #include <curl/curl.h>
     26 
     27 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_PRIMARY_IP, char **ip);
     28 ~~~
     29 
     30 # DESCRIPTION
     31 
     32 Pass a pointer to a char pointer to receive the pointer to a null-terminated
     33 string holding the IP address of the most recent connection done with this
     34 **curl** handle. This string may be IPv6 when that is enabled. Note that you
     35 get a pointer to a memory area that is reused at next request so you need to
     36 copy the string if you want to keep the information.
     37 
     38 The **ip** pointer is NULL or points to private memory. You MUST NOT free - it
     39 gets freed when you call curl_easy_cleanup(3) on the corresponding curl
     40 handle.
     41 
     42 # %PROTOCOLS%
     43 
     44 # EXAMPLE
     45 
     46 ~~~c
     47 int main(void)
     48 {
     49   char *ip;
     50   CURLcode res;
     51   CURL *curl = curl_easy_init();
     52 
     53   curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
     54 
     55   /* Perform the transfer */
     56   res = curl_easy_perform(curl);
     57   /* Check for errors */
     58   if((res == CURLE_OK) &&
     59      !curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ip) && ip) {
     60     printf("IP: %s\n", ip);
     61   }
     62 
     63   /* always cleanup */
     64   curl_easy_cleanup(curl);
     65 }
     66 ~~~
     67 
     68 # %AVAILABILITY%
     69 
     70 # RETURN VALUE
     71 
     72 curl_easy_getinfo(3) returns a CURLcode indicating success or error.
     73 
     74 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     75 libcurl-errors(3).