cURL / Mailing Lists / curl-library / Single Mail

curl-library

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

From: Lijo Antony <lta_at_one.com>
Date: Sun, 25 Nov 2012 10:26:40 +0400

On 11/21/2012 11:55 PM, Christian Hägele wrote:
>
> 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.

Thank you for your suggestion. Though I was aware that this connect was
blocking, I thought, I had no other option. I have removed this connect.

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

I have added this point as a note in my blog post.

I have updated the sample program to avoid connect. As a result, sockopt
callback has been removed and the program became smaller as well. Please
find the patch attached.

-lijo

Received on 2012-11-25