send/write event question

Nulik Nol nuliknol at
Mon Aug 29 13:47:11 CEST 2011

I was reading the documentation but I yet do not understand how should
I use libev for writing to a socket. For reading it is easy, you just
register a EV_READ event and wait for it. But for writing it is not so
clear. Should I just put a send() or write() syscall in my code where
i supposed to do the writing ? Or should I create a watcher with
EV_WRITE flag? Then , how would libev know that my application wants
to write ? Lets suppose my (client) application has connected to a
server and the socket became writeable. Well, it is fine, but I don't
want to write anything at this time. But at some time, I will have to
write some message to the server, then, how should i implement this so
my write callback would be called when the application wants to write
and the socket is writeable ?

Thanks in advance

The power of zero is infinite

More information about the libev mailing list