are there any simple/example event-driven webservers in C?
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 asyn开发者_高级运维chronous 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.
Here is one which is part of TupleServer source that uses libevent.
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.
精彩评论