Should I use EV_WRITE event?

maarten maarten.foque at
Mon Nov 7 09:49:43 CET 2011

If I understand what you are trying to do in situation B correctly,
that callback function will be called each loop iteration.
Pretty much (while(socket_connected)):callback()

So B is a nono,
if the data to send back is limited A will be sufficient and quickest to


On Mon, 2011-11-07 at 11:23 +0800, 钱晓明 wrote:
> Hi, I am working on libev few days, and there is a question about
> When processed request from client, the server has some data to write
> back. At this time, it can:
> A. write back directly in a loop, until all data has been written
> B. install a EV_WRITE event when client connected, check buffer in the
> callback function, and write back if there is data. The EV_WRITE event
> only install once.
> C. install/start a EV_WRITE event when adding reply data to buffer,
> and in callback function write all data to client, stop EV_WRITE event
> at last before returning from this function.
> Which one is best? How frequent the callback function will be called
> in situation B?
> Thanks in advance!
> Kyle Qian
> _______________________________________________
> libev mailing list
> libev at

More information about the libev mailing list