gnurl_multi_fdset(3)
π gnurl_multi_fdset(3) β the libgnurl manual, but make it make sense
okay so bestie, you're in the libgnurl manual and today's main character is gnurl_multi_fdset(3). buckle up π
β¨ NAME β¨
curl_multi_fdset β extracts file descriptor information from a multi handle. yes, the page is called gnurl but the function is curl, that's just how it is, iykyk π¦
πΈ SYNOPSIS πΈ
#include <gnurl/curl.h>
CURLMcode curl_multi_fdset(CURLM *multi_handle,
fd_set *read_fd_set,
fd_set *write_fd_set,
fd_set *exc_fd_set,
int *max_fd);
π DESCRIPTION π
so this function pulls file descriptor info out of a given multi_handle. libcurl hands you back its fd_set sets, and your app can then select() on them β but bestie, you have to FD_ZERO them yourself first before calling this function, because curl_multi_fdset(3) only adds its own descriptors. it does not zero out or remove anything else that's already chilling in there. π and the second one of those descriptors is ready to be read from or written to, you should call curl_multi_perform(3). periodt.
if the read_fd_set argument isn't a null pointer, it points to an object of type fd_set that, on return, specifies the file descriptors to be checked for being ready to read. π
if the write_fd_set argument isn't a null pointer, it points to an object of type fd_set that on return specifies the file descriptors to be checked for being ready to write. βοΈ
if the exc_fd_set argument isn't a null pointer, it points to an object of type fd_set that on return specifies the file descriptors to be checked for error conditions pending. π
if libcurl sets no file descriptors, max_fd will contain -1 when this function returns. otherwise it'll contain the highest descriptor number libcurl set. and when libcurl returns -1 in max_fd, it's because libcurl is currently doing something your application literally can't monitor with a socket β and unfortunately that means you can't know exactly when the current action is completed using select(). π so you gotta wait a while before you proceed and call curl_multi_perform(3) anyway.
how long to wait tho? unless curl_multi_timeout(3) gives you a lower number, we suggest 100 milliseconds or so β but honestly you might wanna test it out in your own particular conditions to find a suitable value. π₯
when you're doing select(), you should use curl_multi_timeout(3) to figure out how long to wait for action. and call curl_multi_perform(3) even if no activity has been seen on the fd_sets after the timeout expires β otherwise internal retries and timeouts may not work as you'd think and want. no cap. β
π¨ ok this next bit is important so pay attention π¨ if one of the sockets used by libcurl happens to be larger than what can be set in anfd_setβ which on POSIX systems means the file descriptor is larger thanFD_SETSIZEβ then libcurl will try to not set it. setting a too-large file descriptor in anfd_setimplies an out of bounds write which can cause crashes, or worse. π the effect of NOT storing it will possibly save you from the crash, but will make your program NOT wait for sockets it should wait for... π«
π RETURN VALUE π
CURLMcode type, the general libcurl multi interface error code. check libcurl-errors(3) for the deets. π
π¦ SEE ALSO π¦
curl_multi_cleanup(3)curl_multi_init(3)curl_multi_wait(3)curl_multi_timeout(3)curl_multi_perform(3)select(2)
and that's the whole page, bestie!! go forth and select() responsibly π§β¨
mwah π β this came to you from libcurl 7.16.0, dated 2 Jan 2006, and it's page gnurl_multi_fdset(3) out of the libgnurl Manual. slay π
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms