cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Problem when I use libcurl to write and libevent to listen on a socket

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 1 Sep 2012 20:12:28 +0200 (CEST)

On Sat, 1 Sep 2012, Veggie Monster wrote:

> I also remove the handle immediately after multi_socket_action writes the
> GET request.

But knowing when the full GET request has been sent is not necessarily
something easily figured out since libcurl doesn't expose that info in any
straight forward way.

> I don't know what would happen if I leave the easy handle in the multi
> handle list.

As I mentioned, libcurl is designed to do HTTP requests and that implies that
it will read the response as well.

>> Why not let libcurl do the HTTP protocol which it was designed to and then
>> you can take care of the data once libcurl hands it to you?
>
> Maybe it is a good idea, but it needs more work, handling incoming traffic
> by libevent was already implemented.

Right, but now you're instead working hard to fight against libcurl and you're
probably even relying on some timing or accidental events with a high risk of
breaking if the network situation changes. Like for other users with other
setups or on other operating systems or versions.

But you're of course free to do it however you want.

> There's a specific name when a program does not do what's suggested by API
> guide. It is called "a bug".

I really don't see how I deserve a snarky comment here.

> And the way to deal with it is either to change the program or the API.

Or I respond to explicit questions on this mailing list and tell you how the
code really works and what the intent is. After all, I wrote large portions of
it. And sure, we might need to update the docs to better explain something if
it doesn't already.

> Here it says if we need to do a specific action then we need to set
> ev_bitmask:
>
> http://curl.haxx.se/libcurl/c/curl_multi_socket_action.html
>
> "When the events on a socket are known, they can be passed as an events
> bitmask ev_bitmask "

Yes, that tells libcurl which action to do on the given socket. It is not a
guarantee that libcurl won't do other stuff that it thinks is necessary. I
don't think the documentation says anything like that.

What are you suggesting we should add to that man page to clarify?

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