curl_multi_get_handles(3)
β¨ curl_multi_get_handles β¨
okay bestie, this one is from the libcurl manual, page curl_multi_get_handles(3), and it's genuinely one of the cutest little functions once you get what it does π«Ά
πΈ NAME πΈ
curl_multi_get_handles β return all added easy handles π
π¦ SYNOPSIS π¦
#include <curl/curl.h>
CURL **curl_multi_get_handles(CURLM *multi_handle);
π DESCRIPTION π
So basically it returns an array with pointers to all the added easy handles. Slay. The end of the list is marked with a NULL pointer, so you just walk it until you hit that NULL and you're done β¨
And listen β even if you haven't added a single easy handle, it still returns an array, just one that has only a single NULL pointer entry in it. Empty but valid, main character energy π
The returned array contains all the handles that are present at the time of the call. The way that timing works: as soon as a handle has been removed from the multi handle, or a handle has been added to it, after the handle array was returned, the two data points are out of sync. So don't be surprised when they disagree π
Also the order of the easy handles within the array is not guaranteed, so please don't index into it and assume anything, bestie π
And the important bit: the returned array may not be overwritten, and it must be freed with a call to curl_free(3) after use. Free it. Free ittt π
π PROTOCOLS π
This functionality affects all supported protocols β every single one, no cap π
π EXAMPLE π
int main(void)
{
/* init a multi stack */
CURLM *multi = curl_multi_init();
CURL *curl = curl_easy_init();
if(curl) {
/* add the transfer */
curl_multi_add_handle(multi, curl);
/* extract all added handles */
CURL **list = curl_multi_get_handles(multi);
if(list) {
int i;
/* remove all added handles */
for(i = 0; list[i]; i++) {
curl_multi_remove_handle(multi, list[i]);
}
curl_free(list);
}
}
}
see how the loop is literally just list[i] until it's falsy? that's the NULL terminator doing its thing, iconic β
π§ AVAILABILITY π§
Added in curl 8.4.0 β so if your curl is older than that, this function simply does not exist for you, sorry babe π
π₯ RETURN VALUE π₯
Returns NULL on failure. Otherwise it returns a pointer to an allocated array π
bestie reminder: that array is allocated, so curl_free(3) it when you're done. Don't leave it hanging π
π SEE ALSO π
and that's the whole page, bestie π«Ά this one's from libcurl, dated 2026-10-12 β go forth and get those handles π
β¨
π¦ 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