Example unix socket echo server
AJ ONeal
coolaj86 at gmail.com
Sat Oct 30 09:36:55 CEST 2010
*unix socket*, not tcp. That will be next. Should be just a few minor edits.
On Sat, Oct 30, 2010 at 1:35 AM, AJ ONeal <coolaj86 at gmail.com> wrote:
> I just put up a tcp example that works.
>
> Earlier I had forgot to `listen` after binding and hence the socket was
> erroneously `ready`
>
> I would really appreciate some feedback from those who use libev as to how
> to make it a better example. I think that the first thing I'll need to do is
> to add a custom struct to get rid of the globals.
>
>
> http://github.com/coolaj86/libev-examples<http://github.com/coolaj86/libev-examples/blob/master/unix-echo.c>
>
> As an ultimate goal it would be great to have a chat server that allows
> http, tcp, and unix socket clients, stdin, and maybe even ev_stat as well.
>
> An awesome intermediate goal is to have an echo server of one of each,
> which I personally can probably do.
>
> AJ ONeal
>
>
>
> On Fri, Oct 29, 2010 at 5:29 PM, AJ ONeal <coolaj86 at gmail.com> wrote:
>
>> Yup, that's the udp example posted on my github account.
>>
>> However, it doesn't even set the socket to nonblock, so I don't think that
>> it's actually using libev the way it was intended.
>>
>> AJ ONeal
>>
>>
>>
>> On Fri, Oct 29, 2010 at 5:06 PM, Rasmus Andersson <rasmus at notion.se>wrote:
>>
>>> Here's a datagram/UDP echo server previously posted on this list,
>>> which might help you:
>>> http://lists.schmorp.de/pipermail/libev/2010q1/001010.html
>>>
>>> On Sat, Oct 30, 2010 at 00:25, AJ ONeal <coolaj86 at gmail.com> wrote:
>>> > 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
>>> >
>>> > _______________________________________________
>>> > libev mailing list
>>> > libev at lists.schmorp.de
>>> > http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
>>> >
>>>
>>>
>>>
>>> --
>>> Rasmus Andersson
>>>
>>> _______________________________________________
>>> libev mailing list
>>> libev at lists.schmorp.de
>>> http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20101030/655c28a7/attachment.html>
More information about the libev
mailing list