CURLINFO_CONN_ID.md (1482B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_CONN_ID 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLINFO_XFER_ID (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11 Protocol: 12 - All 13 Added-in: 8.2.0 14 --- 15 16 # NAME 17 18 CURLINFO_CONN_ID - get the ID of the last connection used by the handle 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONN_ID, 26 curl_off_t *conn_id); 27 ~~~ 28 29 # DESCRIPTION 30 31 Pass a pointer to a *curl_off_t* to receive the connection identifier last 32 used by the handle. Stores -1 if there was no connection used. 33 34 The connection id is unique among all connections using the same 35 connection cache. This is implicitly the case for all connections in the 36 same multi handle. 37 38 # %PROTOCOLS% 39 40 # EXAMPLE 41 42 ~~~c 43 int main(void) 44 { 45 CURL *curl = curl_easy_init(); 46 if(curl) { 47 CURLcode res; 48 49 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 50 51 /* Perform the request */ 52 res = curl_easy_perform(curl); 53 54 if(!res) { 55 curl_off_t conn_id; 56 res = curl_easy_getinfo(curl, CURLINFO_CONN_ID, &conn_id); 57 if(!res) { 58 printf("Connection used: %" CURL_FORMAT_CURL_OFF_T "\n", conn_id); 59 } 60 } 61 } 62 } 63 ~~~ 64 65 # %AVAILABILITY% 66 67 # RETURN VALUE 68 69 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 70 71 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 72 libcurl-errors(3).