quickjs-tart

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

CURLINFO_LASTSOCKET.md (2047B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLINFO_LASTSOCKET
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLINFO_ACTIVESOCKET (3)
      9   - CURLOPT_CONNECT_ONLY (3)
     10   - curl_easy_getinfo (3)
     11   - curl_easy_setopt (3)
     12 Protocol:
     13   - All
     14 Added-in: 7.15.2
     15 ---
     16 
     17 # NAME
     18 
     19 CURLINFO_LASTSOCKET - get the last socket used
     20 
     21 # SYNOPSIS
     22 
     23 ~~~c
     24 #include <curl/curl.h>
     25 
     26 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LASTSOCKET, long *socket);
     27 ~~~
     28 
     29 # DESCRIPTION
     30 
     31 Deprecated since 7.45.0. Use CURLINFO_ACTIVESOCKET(3) instead.
     32 
     33 Pass a pointer to a long to receive the last socket used by this curl
     34 session. If the socket is no longer valid, -1 is returned. When you finish
     35 working with the socket, you must call curl_easy_cleanup(3) as usual and
     36 let libcurl close the socket and cleanup other resources associated with the
     37 handle. This is typically used in combination with
     38 CURLOPT_CONNECT_ONLY(3).
     39 
     40 NOTE: this API is deprecated since it is not working on win64 where the SOCKET
     41 type is 64 bits large while its 'long' is 32 bits. Use the
     42 CURLINFO_ACTIVESOCKET(3) instead, if possible.
     43 
     44 # %PROTOCOLS%
     45 
     46 # EXAMPLE
     47 
     48 ~~~c
     49 int main(void)
     50 {
     51   CURL *curl = curl_easy_init();
     52   if(curl) {
     53     CURLcode res;
     54     long sockfd; /* does not work on win64 */
     55     curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
     56 
     57     /* Do not do the transfer - only connect to host */
     58     curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
     59     res = curl_easy_perform(curl);
     60     if(res != CURLE_OK) {
     61       printf("Error: %s\n", curl_easy_strerror(res));
     62       curl_easy_cleanup(curl);
     63       return 1;
     64     }
     65 
     66     /* Extract the socket from the curl handle */
     67     res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd);
     68     if(!res && sockfd != -1) {
     69       /* operate on sockfd */
     70     }
     71 
     72     curl_easy_cleanup(curl);
     73   }
     74 }
     75 ~~~
     76 
     77 # %AVAILABILITY%
     78 
     79 # RETURN VALUE
     80 
     81 curl_easy_getinfo(3) returns a CURLcode indicating success or error.
     82 
     83 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     84 libcurl-errors(3).