Original article link http://www.wangafu.net /~ Nickm/libevent-book/ref0_meta.html
Libevent User Manual: foresight
Overview:
Libevent is a library used to write high-performance cross-platform non-blocking Io programs. Its Design goals are as follows:
Cross-platform
A program using libevent should be able to run on various platforms supported by libevent. even if sometimes (a platform may) does not have a good way to implement non-blocking Io, libevent should also use a so-so method, in this way, your program can run in a harsh environment.
High Speed
Libevent uses the fastest non-blocking I/O implementation available on different platforms without introducing too much other overhead.
Scalability
Libevent is designed to work well even when processing thousands of active connections.
Convenience
At any time, the most natural way to write a program with libevent should be a stable and cross-platform method.
Libevent consists of the following parts:
Evutil
A set of general functions abstracted for networks on different platforms
Event and event_base
This is the core part of libevent. it abstracts a set of Apis Based on Event-based nonblocking Io backends for various platforms. it tells you when sockets is readable or writable, provides basic time-out functions, and can detect Operating System signals.
Bufferevent
These functions provide more convenient Packaging Based on libevent's event-based core code. they make your application request buffered read/write, so they will notify you only when the real Io occurs, rather than when the socket can be read and written.
The bufferevent interface has different backend implementations, so it can take full advantage of the fast implementation of non-blocking Io provided by different platforms, such as the iocp API in windows.
Evbuffer
This module implements buffer as the basis of bufferevents and provides efficient and easy-to-use functions.
Evhttp
A simple HTTP client/server implementation
Evdns
A simple DNS Client/Server implementation
Evrpc
A simple RPC implementation
Library
When libevent is installed, the following libraries are installed by default:
Libevent_core
Contains all core events and buffer functions. This library contains all event_base, evbuffer, bufferevent, and public functions.
Libevent_extra
This library contains some features related to specific protocols that your program may use, such as HTTP, DNS, and RPC.
Libevent
This library exists for some historical reasons. It includes the libevent_core and libevent_extra features. You should not use this library and it will disappear in future libevent versions.
The following libraries are installed on some platforms:
Libevent_pthreads
This library adds the implementation of threads and locks Based on the cross-platform thread library. this library and libevent_core are separated, so when you use libevent, unless you really need to use libevent in multiple threads, you do not need to link this library.
Libevent_openssl
This library uses the bufferevents and OpenSSL libraries to provide encrypted communication functions. this library is separate from libevent_core, so when you use libevent, you do not need to link OpenSSL unless you really need to use encrypted connections.
Header file
All header files are stored in the event2 directory. These header files can be divided into three types:
API header file
An API header file defines some public interfaces of libevent. The names of these header files do not contain suffixes.
Compatibility header file
The Compatibility header file defines some obsolete functions. Unless you want to migrate your program from the earlier version of libevent, you should not use these header files.
Struct header file
These header files define the structure of relatively unstable components (these headers define structures with relatively volatile layouts ). these structures are exposed to you. First, in case you need to quickly access the structure, some are for historical reasons. if your program directly depends on the structure in these header files, it may cause binary compatibility problems between your program and different versions of libevent, and it is difficult to debug. these header files include "_ struct. h.
R0: foresight