curl-library
Re: Problem when I use libcurl to write and libevent to listen on a socket
Date: Sun, 2 Sep 2012 23:40:46 +0200 (CEST)
On Sat, 1 Sep 2012, Veggie Monster wrote:
>> What are you suggesting we should add to that man page to clarify?
>
> I think something like your sentence makes it much clearer:
>
> "It is not a guarantee that libcurl won't do other stuff that it thinks is
> necessary."
I disagree. Written like that it would be terrible. The documentation doesn't
state anywhere that it would only touch a single connection when called - that
was for some reason only what you seems to have thought when you read it. It
is the multi interface and you drive multiple transfers with it. Of course it
will make what it can to make sure all transfers run and are handled.
If we're going to add something to that man page in this vein, it must be much
clearer than that weird phrase I wrote.
> But now it raises the question that what's the point of having "action"
> argument for socket_multi_action at all:
To make libcurl perform way faster. If you tell libcurl which activity you
detected on a socket, libcurl won't have to waste a system call to figure that
out (again) and when you scale up this problem to 10K connections or something
like that we can see that it does a *significant* impact.
> - If the action is not necessary and you call m_s_a with that specific
> action nothing happens.
I don't understand this point at all. What do you mean nothing happens? Why
wouldn't libcurl do a whole lot of stuff if you call it after a given activity
has occurred?
> - If libevent tells me the action is necessary and I call m_s_a without that
> action, libcurl will take care of it (at least eventually) anyway.
libevent doesn't tell you action "is necessary". libevent tells you that
there's acticity on a socket and that's the info you pass on to libcurl. And
yes, if you don't specify which action it was libcurl will figure it out (in a
slower fashion) and deal with it. Why is that bad for you?
> - If the action is necessary and I call it the action, you say there is no
> guarantee that the job be completed at that call.
Sorry I don't get what "the job" is in this context. When you call
curl_multi_socket_action() with a given activity, libcurl will act on that. It
is of course not a gurarantee that the entire HTTP request has been sent in
that single call, or that it read the entire response or anything. It just
means that libcurl acted on the socket according to the activity signalled by
you. You may have to call the function many times for it to complete whatever
it is doing.
> why not just wait for some event and in the callback, call
> multi_socket_action without any action and it seems to me that everything
> will be the same
You can do that, as I've explained here and I believe the man page says so
too.
> (maybe some timing different but we have no control over the time anyway).
We can do better or worse in regards to transfer performance. I've tried to
make the API not be in the way to achieve really good transfer performance,
even when using very large amounts of parallel transfers.
-- / daniel.haxx.se ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2012-09-02