CURLINFO_CONN_ID(3)
π CURLINFO_CONN_ID β like, the ID of the last connection, bestie
okay so this is a page from the Library Functions Manual (that's the manual name, mwah π) and it's all about CURLINFO_CONN_ID. Buckle in, it's short and iconic.
β¨ NAME β¨
CURLINFO_CONN_ID β the ID of the last connection π
πΈ SYNOPSIS πΈ
#include <curl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONN_ID,
curl_off_t *conn_id);
π¦ DESCRIPTION π¦
okay so you pass in a pointer to a curl_off_t and it receives the connection identifier that the handle used last. that's it, that's the whole vibe π
and listen β if there was, like, no connection used at all? it stores -1. no cap, that's your "nobody home" signal π
now the important part: the connection id is unique among all connections using the same connection cache. and since all connections in the same multi handle implicitly share that cache, yeah β that's the case for them too. iykyk β¨
π₯ PROTOCOLS π₯
this functionality affects all supported protocols β every single one, periodt π
π§ EXAMPLE π§
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode result;
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
/* Perform the request */
result = curl_easy_perform(curl);
if(!result) {
curl_off_t conn_id;
result = curl_easy_getinfo(curl, CURLINFO_CONN_ID, &conn_id);
if(!result) {
printf("Connection used: %" CURL_FORMAT_CURL_OFF_T "\n", conn_id);
}
}
}
}
look at that. curl_easy_init, curl_easy_setopt with CURLOPT_URL, curl_easy_perform, then curl_easy_getinfo with CURLINFO_CONN_ID grabbing your conn_id and printing "Connection used: %" CURL_FORMAT_CURL_OFF_T "\n". the printf ate, fr fr π
β AVAILABILITY β
added in curl 8.2.0 β so if you're on anything older, sorry bestie, it's giving not-yet π
π RETURN VALUE π
curl_easy_getinfo(3) returns a CURLcode indicating success or error.
CURLE_OK (0) means everything was OK. non-zero means an error occurred β go check libcurl-errors(3) for the deets π«Ά
π SEE ALSO π
go touch grass after this, but like, after you read the also-sees. balance π
libcurl Β· 2026-10-12 Β· that's the source/version and date, bestie β this page is a wrap, mwah ππ¦β¨
π¦ where this page comes from
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- fedora 44: libcurl-devel 8.18.0-14.fc44 Β· curl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms