libevent成分

本文详细解读Libevent的核心组件及其在不同网络平台的抽象接口实现,包括事件和事件基、缓冲事件、HTTP、DNS、RPC等功能,以及其提供的库结构和安装方式。重点介绍了如何利用Libevent进行非阻塞I/O操作,以及如何选择合适的库来满足特定的应用需求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

evutil

Generic functionality to abstract out the differences between different platforms' networking implementations.

抽象的不同网络平台的网络接口

event and event_base

This is the heart of Libevent. It provides an abstract API to the various platform-specific, event-based nonblocking IO backends. It can let you know when sockets are ready to read or write, do basic timeout functionality, and detect OS signals.

这个是libevent的核心部分,它提供了各种平台指定的抽象接口,它后端是非阻塞的IO,它给外部提供各种事件信号:读、写、超时,分发系统信号。

bufferevent

These functions provide a more convenient wrapper around Libevent’s event-based core. They let your application request buffered reads and writes, and rather than informing you when sockets are ready to do, they let you know when IO has actually occurred.

这里面的方法是基于event-base提供了一套包装方法,它可以让你方便的请求读或者写,

The bufferevent interface also has multiple backends, so that
it can take advantage of systems that provide faster ways to do
nonblocking IO, such as the Windows IOCP API.
针对各种系统,提供了更加快速的抽象接口,比如windows 的IOCP
evbuffer

This module implements the buffers underlying bufferevents, and provides functions for efficient and/or convenient access.

这个模块继承于bufferevents,他能提供一些有效的方法调用

evhttp

A simple HTTP client/server implementation.

一个简单的http服务器/客户端实现

evdns

A simple DNS client/server implementation.

一个简单dns服务器/客户端实现

evrpc

A simple RPC implementation.

一个简单的RPC实现

When Libevent is built, by default it installs the following libraries:

libevent_core

All core event and buffer functionality. This library contains all the event_base, evbuffer, bufferevent, and utility functions.

核心和基本库都在这里面

libevent_extra

This library defines protocol-specific functionality that you may or may not want for your application, including HTTP, DNS, and RPC.

提供一些扩展协议函数

libevent

This library exists for historical reasons; it contains the contents of both libevent_core and libevent_extra. You shouldn’t use it; it may go away in a future version of Libevent.

这个不要用,它未来可能会去除掉

The following libraries are installed only on some platforms:

libevent_pthreads

This library adds threading and locking implementations based on the pthreads portable threading library. It is separated from libevent_core so that you don’t need to link against pthreads to use Libevent unless you are actually using Libevent in a multithreaded way.

这个库添加了线程库支持,默认不用链接

libevent_openssl

This library provides support for encrypted communications using bufferevents and the OpenSSL library. It is separated from libevent_core so that you don’t need to link against OpenSSL to use Libevent unless you are actually using encrypted connections.

   如果你想加密网络连接,那么你可以添加上这个库


All current public Libevent headers are installed under the event2 directory. Headers fall into three broad classes:

所有的头文件都在 event2这个文件夹中,其他文件夹的头文件不要用那个是兼容老版本的

API headers

An API header is one that defines current public interfaces to Libevent. These headers have no special suffix.

Compatibility headers

A compatibility header includes definitions for deprecatedfunctions. You shouldn’t include it unless you’re porting a program from an older version of Libevent.

Structure headers

These headers define structures with relatively volatile layouts. Some of these are exposed in case you need fast access to structure component; some are exposed for historical reasons. Relying on any of the structures in headers directly can break your program’s binary compatibility with other versions of Libevent, sometimes in hard-to-debug ways. These headers have the suffix "_struct.h"

(There are also older versions of the Libevent headers without the event2 directory. See "If you have to work with an old version of Libevent" below.)



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

美了美了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值