Question

There are many example thread based web servers online, but I haven't really seen anything that gives a good example of an event-loop based one (without being very complex, e.g. lighttp and nginx).

Are there any? If not, what should I read/look at to help me learn how to make a server of this sort? (This includes asynchronous IO in C, etc.)

I already understand the basics of how event-loop based programming works, especially in higher level languages like Python, but I need to be able to implement one in C.

Was it helpful?

Solution

Here is one which is part of TupleServer source that uses libevent.

OTHER TIPS

Not sure how full featured your server needs to be, but here's a small C based web server that could be used as a starting point. It forks a child process for each connection, so it's easy to understand, but not the most efficient.

In short, simple : libevent.org and example : http://www.wangafu.net/~nickm/libevent-book/ . As long as you get your hand in libevent, it's API working with http which is evhttp is not really robust, there is an alternative at https://github.com/ellzey/libevhtp . And of course libmicrohttpd works just fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top