1curl_multi_fdset(3)             libcurl Manual             curl_multi_fdset(3)
2
3
4

NAME

6       curl_multi_fdset  -  extracts  file descriptor information from a multi
7       handle
8

SYNOPSIS

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

DESCRIPTION

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 the read_fd_set argument is not a null  pointer,  it  points  to  an
28       object of type fd_set that on returns specifies the file descriptors to
29       be checked for being ready to read.
30
31       If the write_fd_set argument is not a null pointer,  it  points  to  an
32       object  of type fd_set that on return specifies the file descriptors to
33       be checked for being ready to write.
34
35       If the exc_fd_set argument is not a  null  pointer,  it  points  to  an
36       object  of type fd_set that on return specifies the file descriptors to
37       be checked for error conditions pending.
38
39       If no file descriptors are set by libcurl, max_fd will contain -1  when
40       this function returns. Otherwise it will contain the highest descriptor
41       number libcurl set. When libcurl returns -1 in max_fd,  it  is  because
42       libcurl  currently does something that isn't possible for your applica‐
43       tion to monitor with a socket and unfortunately you can then  not  know
44       exactly  when  the current action is completed using select(). You then
45       need to wait a while before you proceed and call  curl_multi_perform(3)
46       anyway.  How  long  to  wait?  Unless curl_multi_timeout(3) gives you a
47       lower number, we suggest 100 milliseconds or so, but you  may  want  to
48       test it out in your own particular conditions to find a suitable value.
49
50       When doing select(), you should use curl_multi_timeout(3) to figure out
51       how long to wait for action.  Call  curl_multi_perform(3)  even  if  no
52       activity has been seen on the fd_sets after the timeout expires as oth‐
53       erwise internal retries and timeouts may not work as  you'd  think  and
54       want.
55
56       If  one  of  the sockets used by libcurl happens to be larger than what
57       can be set in an fd_set, which on POSIX systems  means  that  the  file
58       descriptor  is larger than FD_SETSIZE, then libcurl will try to not set
59       it. Setting a too large file descriptor in an fd_set implies an out  of
60       bounds write which can cause crashes, or worse. The effect of NOT stor‐
61       ing it will possibly save you from the crash, but will make  your  pro‐
62       gram NOT wait for sockets it should wait for...
63

RETURN VALUE

65       CURLMcode  type,  general  libcurl  multi  interface  error  code.  See
66       libcurl-errors(3)
67

SEE ALSO

69       curl_multi_cleanup(3),     curl_multi_init(3),      curl_multi_wait(3),
70       curl_multi_timeout(3), curl_multi_perform(3), select(2)
71
72
73
74libcurl 7.64.0                 November 09, 2017           curl_multi_fdset(3)
Impressum