quickjs-tart

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

CURLINFO_LOCAL_PORT.md (1421B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLINFO_LOCAL_PORT
      5 Section: 3
      6 Source: libcurl
      7 Protocol:
      8   - TCP
      9   - QUIC
     10 See-also:
     11   - CURLINFO_LOCAL_IP (3)
     12   - CURLINFO_PRIMARY_PORT (3)
     13   - curl_easy_getinfo (3)
     14   - curl_easy_setopt (3)
     15 Added-in: 7.21.0
     16 ---
     17 
     18 # NAME
     19 
     20 CURLINFO_LOCAL_PORT - get the latest local port number
     21 
     22 # SYNOPSIS
     23 
     24 ~~~c
     25 #include <curl/curl.h>
     26 
     27 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LOCAL_PORT, long *portp);
     28 ~~~
     29 
     30 # DESCRIPTION
     31 
     32 Pass a pointer to a long to receive the local port number of the most recent
     33 connection done with this **curl** handle.
     34 
     35 If the connection was done using QUIC, the port number is a UDP port number,
     36 otherwise it is a TCP port number.
     37 
     38 # %PROTOCOLS%
     39 
     40 # EXAMPLE
     41 
     42 ~~~c
     43 int main(void)
     44 {
     45   CURL *curl;
     46   CURLcode res;
     47 
     48   curl = curl_easy_init();
     49   if(curl) {
     50     curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
     51     res = curl_easy_perform(curl);
     52 
     53     if(CURLE_OK == res) {
     54       long port;
     55       res = curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &port);
     56 
     57       if(CURLE_OK == res) {
     58         printf("We used local port: %ld\n", port);
     59       }
     60     }
     61     curl_easy_cleanup(curl);
     62   }
     63   return 0;
     64 }
     65 ~~~
     66 
     67 # %AVAILABILITY%
     68 
     69 # RETURN VALUE
     70 
     71 curl_easy_getinfo(3) returns a CURLcode indicating success or error.
     72 
     73 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     74 libcurl-errors(3).