一个epoll/aio/eventfd结合使用的简单例子
来源:互联网 发布:情义知多少日本电影 编辑:程序博客网 时间:2024/05/16 03:40
#define _GNU_SOURCE
#define __STDC_FORMAT_MACROS
#include <stdio.h>
#include <errno.h>
#include <libaio.h>
#include <sys/eventfd.h>
#include <sys/epoll.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <inttypes.h>
#define TEST_FILE "aio_test_file"
#define TEST_FILE_SIZE (127 * 1024)
#define NUM_EVENTS 128
#define ALIGN_SIZE 512
#define RD_WR_SIZE 1024
struct custom_iocb
{
};
void aio_callback(io_context_t ctx, struct iocb *iocb, long res, long res2)
{
}
int main(int argc, char *argv[])
{
}
说明:
1. 在centos 6.2 (libaio-devel 0.3.107-10) 上运行通过
2. struct io_event中的res字段表示读到的字节数或者一个负数错误码。在后一种情况下,-res表示对应的
3. iocb在aio请求执行过程中必须是valid的
4. 在上面的程序中,通过扩展iocb结构来保存额外的信息(nth_request),并使用iocb.data
0 0
- 一个epoll/aio/eventfd结合使用的简单例子
- 一个epoll/aio/eventfd结合使用的简单例子
- Linux native AIO与eventfd、epoll的结合使用
- Linux native AIO与eventfd、epoll的结合使用
- 一个简单的epoll使用例子
- 一个epoll的简单例子
- 一个简单的epoll测试例子
- 一个简单的epoll小例子
- epoll 使用简单例子
- inotify和epoll结合使用的小例子
- epoll的使用例子
- Epoll例子的使用
- Linux eventfd的使用
- epoll应用的一个例子
- epoll应用的一个例子
- epoll使用的一个小例子,非常实用
- epoll使用的一个小例子,非常实用
- 一个小例子演示下epoll和管道的使用
- 设计模式之-----中介者模式
- 整数划分问题--DFS
- 简单Git Server搭建及其测试
- MVC中的Html.ActionLink的介绍
- 面试中的链表题目
- 一个epoll/aio/eventfd结合使用的简单例子
- NHibernate3剖析:Mapping篇之ConfORM实战(2):原理
- 在Eclipse中使用Maven建立Spring项目
- UNIX网络编程卷一:第十四章 高级I/O
- NHibernate3剖析:Query篇之NHibernate.Linq自定义扩展
- 【Linux目录】远离 /usr/local, /opt
- aspx repeate控件多级关联
- 卡特兰数的证明及应用
- 快速排序