xref: /curl/docs/libcurl/opts/CURLINFO_XFER_ID.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLINFO_XFER_ID
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_CONN_ID (3)
9  - curl_easy_getinfo (3)
10  - curl_easy_setopt (3)
11Protocol:
12  - All
13Added-in: 8.2.0
14---
15
16# NAME
17
18CURLINFO_XFER_ID - get the ID of a transfer
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_XFER_ID,
26                           curl_off_t *xfer_id);
27~~~
28
29# DESCRIPTION
30
31Pass a pointer to a *curl_off_t* to receive the identifier of the
32current/last transfer done with the handle. Stores -1 if no transfer
33has been started yet for the handle.
34
35The transfer id is unique among all transfers performed using the same
36connection cache. This is implicitly the case for all transfers in the
37same multi handle.
38
39# %PROTOCOLS%
40
41# EXAMPLE
42
43~~~c
44int main(void)
45{
46  CURL *curl = curl_easy_init();
47  if(curl) {
48    CURLcode res;
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 xfer_id;
56      res = curl_easy_getinfo(curl, CURLINFO_XFER_ID, &xfer_id);
57      if(!res) {
58        printf("Transfer ID: %" CURL_FORMAT_CURL_OFF_T "\n", xfer_id);
59      }
60    }
61  }
62}
63~~~
64
65# %AVAILABILITY%
66
67# RETURN VALUE
68
69Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
70