Are there any simple / sample event driven web servers in C?

There are many examples of thread-based web servers on the Internet, but I have not seen anything that gives a good example of an event-based loop (without complexity, such as lighttp and nginx).

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

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

+6
source share
3 answers

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

+2
source

Not sure how full your server should be, but here is a small C-based web server that can be used as a starting point. It creates a child process for each connection, so it is easy to understand, but not the most efficient.

0
source

In short, simple: libevent.org and example: http://www.wangafu.net/~nickm/libevent-book/ . As long as you get your hand at libevent, the http API that is evhttp is not really reliable, there is an alternative to https://github.com/ellzey/libevhtp , and of course libmicrohttpd works fine.

0
source

Source: https://habr.com/ru/post/890298/


All Articles