Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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.

like image 817
Aaron Yodaiken Avatar asked Jun 11 '11 17:06

Aaron Yodaiken


People also ask

Is event-driven programming single threaded?

Event-driven programming requires less memory than multi-threaded programming because there are no threads that require stack memory. The entire system can run as a single thread, which requires only one single stack.

What is event based programming in C?

In computer programming, event-driven programming is a programming paradigm in which the flow of the program is determined by events such as user actions (mouse clicks, key presses), sensor outputs, or message passing from other programs or threads.

What do u mean by event-driven programming?

An event-driven application is a computer program that is written to respond to actions generated by the user or the system. In a computing context, an event is any identifiable occurrence that has significance for system hardware or software.

What is an event-driven server?

An event-driven server typically has a single thread which manages all connections to the server. The thread uses the select() system call to simultaneously wait for events on these connections. When a call to select() returns, the server's main loop invokes event handlers for each of the ready descriptors.


1 Answers

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

like image 65
Andrew White Avatar answered Sep 27 '22 22:09

Andrew White