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