asynchronous socket writing

Maarten Foqué maarten.foque at
Thu Mar 11 10:35:32 CET 2010

If this is your first go with C and sockets, I suggest you leave the
multi-threaded thing be for a while.
To use libev and socket you first want to understand how it works or you
may end up rewriting your application.
For libev I suggest looking at the documentation and starting with a
simple timer watcher and idle watcher, see how it works.

For sockets try something simple to exchange some data with a program in
a language you know.  Also take a good look at the ioctl and fcntl
functions.  These can put a socket in non_blocking mode, or tell you
that a socket has bytes ready for reading.

I'm using libev as a socket_server on one end and to listen for notifies
from the db on the other end.  
This works much faster than I need and doesn't require any threading.


On Wed, 2010-03-10 at 19:15 +0100, Jonas H. wrote:
> Hello there,
>    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 decided to have a single accept/listen/whatever thread for now. 
> However, I want asynchronous read at write (at least write).
>    So the question is: How do I implemented asynchronous I/O?
> (Maybe this isn't /too/ libev specific but more a general question.)
>    If I get things right, the UNIX `read`/`recv` and `write`/`send` 
> aren't non-blocking/asynchronous. Putting the write stuff into an own 
> thread does not change anything.  Did I get something wrong?
> I'm grateful for any tips. Thanks! :-)
>      Jonas
> _______________________________________________
> libev mailing list
> libev at

More information about the libev mailing list