curl\_multi\_waitfds(3) Library Functions Manual curl\_multi\_waitfds(3)

# [NAME](#NAME)

curl\_multi\_waitfds - extract file descriptor information from a multi handle

# [SYNOPSIS](#SYNOPSIS)

```
#include <curl/curl.h>
#include <stdlib.h>
CURLMcode curl_multi_waitfds(CURLM *multi,


                             struct curl_waitfd *ufds,


                             unsigned int size,


                             unsigned int *fd_count);
```

# [DESCRIPTION](#DESCRIPTION)

This function extracts *curl\_waitfd* structures which are similar to [*poll(2)*](/man/os/curl/poll.2)'s *pollfd* structure from a given multi\_handle.

These structures can be used for polling on multi\_handle file descriptors in a fashion similar to [*curl\_multi\_poll(3)*](/man/os/curl/curl_multi_poll.3). The [*curl\_multi\_perform(3)*](/man/os/curl/curl_multi_perform.3) function should be called as soon as one of them is ready to be read from or written to.

libcurl fills provided *ufds* array up to the *size*. If a number of descriptors used by the multi\_handle is greater than the *size* parameter then libcurl returns CURLM\_OUT\_OF\_MEMORY error.

If the *fd\_count* argument is not a null pointer, it points to a variable that on return specifies the number of descriptors used by the multi\_handle to be checked for being ready to read or write.

The client code can pass *size* equal to zero to get the number of the descriptors and allocate appropriate storage for them to be used in a subsequent function call. In this case, *fd\_count* receives a number greater than or equal to the number of descriptors.

# [PROTOCOLS](#PROTOCOLS)

This functionality affects all supported protocols

# [EXAMPLE](#EXAMPLE)

```
#include <stdlib.h>
int main(void)
{


  CURLMcode mresult;


  struct curl_waitfd *ufds;


  CURLM *multi = curl_multi_init();


  do {


    /* call curl_multi_perform() */


    /* get the count of file descriptors from the transfers */


    unsigned int fd_count = 0;


    mresult = curl_multi_waitfds(multi, NULL, 0, &fd_count);


    if(mresult != CURLM_OK) {


      fprintf(stderr, "curl_multi_waitfds() failed, code %d.\n", mresult);


      break;


    }


    if(!fd_count)


      continue; /* no descriptors yet */


    /* allocate storage for our descriptors */


    ufds = malloc(fd_count * sizeof(struct curl_waitfd));


    /* get wait descriptors from the transfers and put them into array. */


    mresult = curl_multi_waitfds(multi, ufds, fd_count, &fd_count);


    if(mresult != CURLM_OK) {


      fprintf(stderr, "curl_multi_waitfds() failed, code %d.\n", mresult);


      free(ufds);


      break;


    }


    /* Do polling on descriptors in ufds */


    free(ufds);


  } while(!mresult);
}
```

# [AVAILABILITY](#AVAILABILITY)

Added in curl 8.8.0

# [RETURN VALUE](#RETURN_VALUE)

This function returns a CURLMcode indicating success or error.

CURLM\_OK (0) means everything was OK, non-zero means an error occurred, see [*libcurl-errors(3)*](/man/os/curl/libcurl-errors.3).

# [SEE ALSO](#SEE_ALSO)

[**curl\_multi\_fdset**(3)](/man/os/curl/curl_multi_fdset.3), [**curl\_multi\_perform**(3)](/man/os/curl/curl_multi_perform.3), [**curl\_multi\_poll**(3)](/man/os/curl/curl_multi_poll.3), [**curl\_multi\_wait**(3)](/man/os/curl/curl_multi_wait.3)

2026-10-19 libcurl

---

Document: curl_multi_waitfds(3) from curl 8.23.0-r1 (Chainguard OS)
Source: https://github.com/curl/curl.git
