On Tue, Nov 2, 2010 at 08:41, Marc Lehmann <[email protected]> wrote:
> On Mon, Nov 01, 2010 at 10:44:58PM -0600, AJ ONeal <[email protected]> wrote:
>> The question that I have is if it's true to say that a unix socket is
>> writable whenever it is readable?
>
> No, a unix domain socket works mostly like other stream sockets.
>
>> When I tried listening for when it was writable, it seemed to fire the event
>> over and over again.
>
> Do you have reason to assume that it was not writable over and over again?
>
> For it not to be writable you'd have to write enough data to fill it's
> buffers, and make sure nobody is reading on the other side.
>
>> Or is it that when I want to send data I should
>>     start the watcher for writes
>>     send the data
>>     stop the watcher
>> ?
>
> If you mean your write watcher was always active, then this explains your
> issue. Think about it, you ask libev when the socket is writable, but
> don't write anything. This means the socket will stay writable - there is
> no way for libev to know thta for some reason you are no longer interested
> in writability, except by stopping the watcher.
>
> A common (not necessarily most efficient) way to handle writes is:
>
>   start the watcher
>   in callback
>      write more of the remaining data
>      if all data has been written, stop the watcher

kind of off-topic, but why send()/recv() instead of write()/read() ?

_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to