1CURLINFO_LASTSOCKET(3) curl_easy_getinfo options CURLINFO_LASTSOCKET(3)
2
3
4
6 CURLINFO_LASTSOCKET - get the last socket used
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_LASTSOCKET, long
12 *socket);
13
15 Deprecated since 7.45.0. Use CURLINFO_ACTIVESOCKET(3) instead.
16
17 Pass a pointer to a long to receive the last socket used by this curl
18 session. If the socket is no longer valid, -1 is returned. When you
19 finish working with the socket, you must call curl_easy_cleanup() as
20 usual and let libcurl close the socket and cleanup other resources
21 associated with the handle. This is typically used in combination with
22 CURLOPT_CONNECT_ONLY(3).
23
24 NOTE: this API is deprecated since it is not working on win64 where the
25 SOCKET type is 64 bits large while its 'long' is 32 bits. Use the
26 CURLINFO_ACTIVESOCKET(3) instead, if possible.
27
29 All
30
32 CURL *curl = curl_easy_init();
33 if(curl) {
34 long sockfd; /* doesn't work on win64! */
35 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
36
37 /* Do not do the transfer - only connect to host */
38 curl_easy_setopt(curl, CURLOPT_CONNECT_ONLY, 1L);
39 res = curl_easy_perform(curl);
40
41 /* Extract the socket from the curl handle */
42 res = curl_easy_getinfo(curl, CURLINFO_LASTSOCKET, &sockfd);
43
44 if(res != CURLE_OK) {
45 printf("Error: %s\n", curl_easy_strerror(res));
46 return 1;
47 }
48 }
49
51 Added in 7.15.2
52
54 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
55 if not.
56
58 curl_easy_getinfo(3), curl_easy_setopt(3), CURLINFO_ACTIVESOCKET(3),
59
60
61
62libcurl 7.71.1 May 06, 2017 CURLINFO_LASTSOCKET(3)