cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Example C++ program to demonstrate the use of multi interface with boost::asio

From: Christian Hägele <haegele_at_teamviewer.com>
Date: Wed, 21 Nov 2012 19:55:13 +0000 (UTC)

Hello,

first of all a big thank you for writing this example. This example would had
saved me a lot of work in the past. I implemented a very similar approach as you
did, but I couldn't and can't share any code.

However, I have 2 additional comments (I haven't tested the code):

1. In the CURLOPT_OPENSOCKETFUNCTION-callback you call connect on the new socket.
That call is *blocking*! You should not do this when using boost::asio. There is
no need to call connect on the socket yourself. The curl-multi-handle will do
that for you in non-blocking manner and just give you the socket to listen on.

2. In the CURLOPT_CLOSESOCKETFUNCTION you have to be aware that the
CURLMOPT_SOCKETFUNCTION might be called afterwards with the *same* socket you
just closed with action CURL_POLL_REMOVE. In my implementation that had some
weird issues and was very hard to find.
In your implementation this should not have any issues, but you should add a
comment about it somewhere in you blog-post or in your code. I wrote about that
issue a couple of time on the mailing-list.

Regards,

Christian

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-11-21