cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Recommended architecture for streaming over multiple sockets

From: Boutin Maël <mael.boutin_at_gmail.com>
Date: Fri, 11 Mar 2016 09:36:09 +0100

>
> 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.
>
> I think i've read the docs tens of times. I'd not have bothered you if it
was clear in my mind :)

 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.
> }

Ok thank you that is what i understood.
I adapted that for my usecase (i have long running never ending HTTP
request. The server in front is not standard)

Again thank you for your kind help.

Best regards,

2016-03-10 22:36 GMT+01:00 Daniel Stenberg <daniel_at_haxx.se>:

> 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
>

-- 
Maël BOUTIN

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