[ccan] Networking: Asynchronous Server+Client socket code

Ahmed Samy f.fallen45 at gmail.com
Sat Nov 3 16:44:32 EST 2012


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20121103/6bad29f3/attachment.html>


More information about the ccan mailing list