are there any simple/example event-driven webservers in C?
Asked Answered
E

3

6

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.

Enfeeble answered 11/6, 2011 at 17:42 Comment(1)
Look at thttpd, and also at GNU libmicrohttpdRunyon
A
2

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

Amii answered 11/6, 2011 at 17:49 Comment(0)
M
0

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.

Maryrosemarys answered 11/6, 2011 at 18:42 Comment(0)
R
0

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.

Rolon answered 17/3, 2014 at 4:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.