[ccan] Networking: Asynchronous Server+Client socket code

Ahmed Samy f.fallen45 at gmail.com
Sat Nov 3 18:03:49 EST 2012


On Sat, Nov 3, 2012 at 5:44 AM, Ahmed Samy <f.fallen45 at gmail.com> wrote:

> Hi,
>
> This is a lightweight networking code that I'd like to add in The ccan
> tree.
> Reading the code should be straight forward, it uses epoll etc, and has
> support for callbacks, it can be used a server or a client with 3 simple
> calls:
>
>
>     struct socket_t *sock = socket_create();
>     if (!socket_listen(sock, NULL, 1337))
>         fatal("failed to listen on port 1337.");
>
>     /*
>      * callbacks should be setup before polling on the socket
>
>      */
>     socket_poll(sock);
>
>
> For client side, replace socket_listen with socket_connect.
> The code can be viewed at: at:
> https://github.com/otfallen/csnippets/blob/master/src/socket.c (to view
> the header change '.c' to '.h')
>
> Please leave any kind of feedback.
>
> Thanks
>       asamy
>
Btw, the tests I used can be found at:
https://github.com/otfallen/csnippets/blob/master/src/tests.c
Also, I sent this message for a discussion, i.e what code can be improved
etc etc.  So, after the code is as-wanted, I'll upload patch(es) with ccan
coding style and so on.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20121103/0a77dbbb/attachment.html>


More information about the ccan mailing list