1curl_multi_fdset(3) libcurl Manual curl_multi_fdset(3)
2
3
4
6 curl_multi_fdset - extracts file descriptor information from a multi
7 handle
8
10 #include <curl/curl.h>
11
12 CURLMcode curl_multi_fdset(CURLM *multi_handle,
13 fd_set *read_fd_set,
14 fd_set *write_fd_set,
15 fd_set *exc_fd_set,
16 int *max_fd);
17
19 This function extracts file descriptor information from a given
20 multi_handle. libcurl returns its fd_set sets. The application can use
21 these to select() on, but be sure to FD_ZERO them before calling this
22 function as curl_multi_fdset(3) only adds its own descriptors, it
23 doesn't zero or otherwise remove any others. The curl_multi_perform(3)
24 function should be called as soon as one of them is ready to be read
25 from or written to.
26
27 If no file descriptors are set by libcurl, max_fd will contain -1 when
28 this function returns. Otherwise it will contain the higher descriptor
29 number libcurl set. When libcurl returns -1 in max_fd, it is because
30 libcurl currently does something that isn't possible for your applica‐
31 tion to monitor with a socket and unfortunately you can then not know
32 exactly when the current action is completed using select(). When
33 max_fd returns with -1, you need to wait a while and then proceed and
34 call curl_multi_perform anyway. How long to wait? I would suggest 100
35 milliseconds at least, but you may want to test it out in your own par‐
36 ticular conditions to find a suitable value.
37
38 When doing select(), you should use curl_multi_timeout to figure out
39 how long to wait for action. Call curl_multi_perform even if no activ‐
40 ity has been seen on the fd_sets after the timeout expires as otherwise
41 internal retries and timeouts may not work as you'd think and want.
42
43 If one of the sockets used by libcurl happens to be larger than what
44 can be set in an fd_set, which on POSIX systems means that the file
45 descriptor is larger than FD_SETSIZE, then libcurl will try to not set
46 it. Setting a too large file descriptor in an fd_set implies an out of
47 bounds write which can cause crashes, or worse. The effect of NOT stor‐
48 ing it will possibly save you from the crash, but will make your pro‐
49 gram NOT wait for sockets it should wait for...
50
52 CURLMcode type, general libcurl multi interface error code. See
53 libcurl-errors(3)
54
56 curl_multi_cleanup(3), curl_multi_init(3), curl_multi_timeout(3),
57 curl_multi_perform(3)
58
59
60
61libcurl 7.16.0 2 Jan 2006 curl_multi_fdset(3)