Can I use ev_loop only for read ?

Marc Lehmann schmorp at
Tue Mar 17 04:00:07 CET 2009

On Sun, Mar 15, 2009 at 12:56:30PM +0800, Terry Xiang <xqterry at> wrote:
>   Oh, I thought reading and writing simultaneously on a full duplex socket
> could get better performance.

Only if reading and writing is indeed more costly than atcually
transporting the data, which is usually not the case. If you don't have
multiple cpus, then you cnanot do this simult. anyways. If you have
multiple cpus, then you have to figure in the communication and locking
overhead involved in accessing the same socket on different cpus (it's
easy to win a factor of ten by not using threads when this happens -
communicaitons via main memory or l2 is slow).

In general, unless you are an expert and feel the need, using threads will
just get you in trouble.

> Could you give me any tip of the good
> solution? Any suggestion will be appreciated.

A good solution is to use e.g. libev or another library and read and wirte in
callbacks. Another goofd solution, is to do it yourself with select, if your
requirements are low. Threads might be a good solution if you need the
highets performance possible on amny (but not all) operating systems.

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

More information about the libev mailing list