curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: curl_multi_timeout and the multi_socket API

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 2 Apr 2021 23:05:44 +0200 (CEST)

On Fri, 2 Apr 2021, Henrik Holst via curl-library wrote:

> for (;;)
> int ret = poll (fds, nfds, timeout);
>
> if (ret == 0) {/* timeout */
> curl_multi_socket_action (curlm, CURL_SOCKET_TIMEOUT, 0,
> &running_handles);
> } else if (ret != -1) { /* events */
> if (fds[0].revents != 0)
> curl_multi_socket_action (curlm, fds[0].fd, fds[0].revents,
> &running_handles);
> else if (fds[1]).revents != 0)
> ...
> }
> }

This is a typical example of an event loop that should rather use
curl_multi_perform() or perhaps even just curl_multi_poll(). And yes, for such
an event loop you want curl_multi_timeout (at least unless you use
curl_multi_poll).

If you use poll() then the multi socket API is probably the wrong choice. The
multi socket API is for event-based handling.

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html
Received on 2021-04-02