cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: async IO using libCURL

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 10 Aug 2010 23:44:54 +0200 (CEST)

On Tue, 10 Aug 2010, Jogeshwar Karthik Akundi wrote:

> Write shouldn't block. I give data to write, CURL would give a
> writeComplete_callback later that write is complete.
> Read shouldn't block. I should get a data_callback whenever data is received
> on socket.

That's not really how it works in anything but Windows perhaps[*].

IO in Linux and unix is generally non-blocking not asynchronous, so you do as
much as possible immediately without blocking, and then you wait for the
socket to have more data or be prepared to get more data.

If you truly want "asynchronous", you build it with threads but the underlying
fundamentals are still "just" non-blocking and libcurl provides such
non-blocking fundamentals just fine.

I'll second Frank's question: what exactly are you planning to do that the
normal multi interface can't do for you?

If you're looking for high performance socket and event handling on *nix, the
answer is rather called libev or libevent rather than anything else - in
combination with libcurl's event-based API multi_socket.

[*] = stuff like SIGIO/SIGPOLL exists, but its not really what anyone uses and
it has significant drawbacks anyway.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2010-08-10