asynchronous socket writing

Marc Lehmann schmorp at
Thu Mar 11 13:53:28 CET 2010

On Wed, Mar 10, 2010 at 07:15:16PM +0100, "Jonas H." <jonas at> wrote:
>   I'm currently taking my first steps in socket/C programming and I want 
> to implement a fast, multi-threaded web server for testing purpose.  I 

If I were you, I'd avoid threads, especially as "my first steps".

> decided to have a single accept/listen/whatever thread for now. However, 
> I want asynchronous read at write (at least write).

Since asynchronous I/O is highly unportable, I would also suggest to avoid
it at all costs.

It is much easier to use an event-based approach without threads, with
normal non-blocking I/O instead.

>   So the question is: How do I implemented asynchronous I/O?

You can't, the OS has to implement it for you.

>   If I get things right, the UNIX `read`/`recv` and `write`/`send`  
> aren't non-blocking/asynchronous.

They are non-blocking when the underlying fd is non-blocking, they are
never asynchronous.

                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_    
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      schmorp at
      -=====/_/_//_/\_,_/ /_/\_\

More information about the libev mailing list