libev TCP echo server example?

Marc Lehmann schmorp at
Sat Mar 27 21:38:54 CET 2010

On Sat, Mar 27, 2010 at 07:21:52PM +0000, Chris Dew <cmsdew at> wrote:
> // Lots of globals, what's the best way to get rid of these?

put them into a struct, maybe together with the watcher(s), and put it's
address intot eh data pointer (or or some othe rtechnique described in the
libev manual).

>     // Echo it back.
>     // WARNING: this is probably not the right way to do it with libev.
>     // Question: should we be setting a callback on sd becomming writable

With TCP, yes, udp effectively never blocks, when the queue is full
instead the packet will be dropped (usually with ENOBUFS).

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

More information about the libev mailing list