cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Recommended architecture for streaming over multiple sockets

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 10 Mar 2016 22:36:23 +0100 (CET)

On Thu, 10 Mar 2016, Boutin Maël wrote:

> Based on your advices i changed my code. It seems to work but do you see
> any flaws there ?
>
> 1. Call multi_perform
> 2. If still running FDs is >= previous running FDs: call multi_wait if
> there are no more data to be sent
> 3. Check the message queue to get ended transfers and reinitiate connection
> if it ended due to an error (by removing the curl handle from multi_handle
> then add a new one).

I think you should consider reading the docs as all of this is explained at
fairly high detail in there. We also have lots of examples showing this.

The above description is close but I think misses some subtleties. This is the
basic loop we recommend.

while there are uncompleted transfers
{
   1. Call curl_multi_perform()

   2. After curl_multi_perform(), check with curl_multi_info_read() if any
      transfer completed and if so, deal with that.

   3. Call curl_multi_wait() to wait for socket activity/timeout.
}

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-03-10