Example unix socket echo server

AJ ONeal coolaj86 at gmail.com
Sat Oct 30 00:25:50 CEST 2010


I spent a few hours reading through the documentation. I didn't understand
all of it, but it was enlightening.

I've done a fair amount of googling and I've found some reference
implementations using libev.

However, I'm now trying to build my own bare-bones socket-based echo server
and I'm not quite sure how to go about it, nor have I found anything n the
middle between between the too simple stdin example and the over-my-head
tcpdns example.



Am I correct that this is what the flow will be like?

   - Server waits for data in non-blocking fashion
   - Event fires when a client connects
   - Server receives data in non-blocking fashion
   - Server chews bubble gum or something for a while, maybe accepts another
   connection...
   - Event fires when data is received
   - Server echos data

Here's the code that I have so far:
http://github.com/coolaj86/libev-examples/blob/master/unix-echo.c

What I don't understand right now is why the socket is ready for reading
when nothing is connecting to it to read from.

AJ ONeal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20101029/5469d1ca/attachment.html>


More information about the libev mailing list