Recommending – SWILL library

SWILL is a simple and powerful C/C++ library that allows you to easily add web-server functionality to your C/C++ programs.

Usage is very simple – swill_init(), swill_handle()/swill_file(), and then swill_serve(). Yes, that’s it, 4 functions to do it all.

SWILL among others takes care of the GET and POST data passed to you, and manages HTTP headers (of course, you can still easily access incoming headers and customize your outgoing headers).

Main disadvantage is, that SWILL can process only one request at a time. If you need parallel processing, see libmicrohttpd.

Here’s a simple example from the SWILL’s homepage:

#include "swill.h"

void count_to_ten(FILE *f)
    int i;
    for (i = 0; i < 10; i++)
        fprintf(f, "%d\n", i);

int main()
    swill_handle("ten.txt", count_to_ten, 0);
    while (1)
    return 0;

On typing http://localhost:8080/ten.txt in your browser you’ll get the numbers 0..9 printed one per line.
Simple and functional – what more do you want? 😉

Happy coding!

6 responses to “Recommending – SWILL library

  1. Как хорошо что удалось отыскать такой замечательный блог, и тем более отлично, что есть такие автора толковые!

  2. Хорошо написано, надо будет скинуть ссылочку товарищам, чтобы и они оценили вашу статью.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s