The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore, libevent also support callbacks due to signals or regular timeouts.
Also this (for .net dev):
Question: libevent, windows and .NET programming?
I experiment with a lot of open source software and I’ve noticed a fair amount of server type applications in the open source world use libevent to facilitate event-based processing rather than spawn multiple threads to handle requests.
I also do a lot of .NET programming (it’s my core job function), and I’m interested in learning how libevent relates to the .NET event model. Are events in .NET the equivalent of libevent for C programs? Should I try to learn libevent and attempt to use it in custom .NET server applications or is using the standard .NET event model basically the same thing?
.NET events and libevent are not equivalent, though they share abstract concepts.
.NET events allow non-deterministic communication between CLR components. In C#, the component is an object - events are class members. In other languages, like F#, objects are not required. An event allows consumers to subscribe to notifications that occur on specific conditions in the source - a button is clicked, a download is complete, an exception occurred, etc. A few characteristics of .NET events:
libevent allows non-deterministic, asynchronous communication between the OS and a consumer. This might feel similar to .NET events because they both invert control, but the mechanisms are very different.
Should I try to learn libevent and attempt to use it in custom .NET server applications…?
If you’re doing it for fun, sure. If you’re doing it for work, probably not. libevent claims its biggest performance gains on *nix systems. Windows uses a different networking paradigm. The libevent developers are addressing these differences in version 2 but 2.0.5 is still a beta release.
In addition, .NET offers its own non-blocking I/O libraries including asynchronous sockets.