epoll基础篇一:
```cpp
struct epoll_event{
__uint32_t events; //Epoll events
epoll_data_t data; //User datavariable
};
typedef union epoll_data{
void* ptr;
int fd;
__uint32_t u32;
__uint64_t u64;
}epoll_data_t;
```cpp
/*description:
*生成一个epoll专用的文件描述符,其实是申请一个内核空间,用来存放你想关注的socket fd是否
*发生以及发生了什么事件。size就是你在这个epoll fd上能关注的最大的socket fd数,大小自定,
*只要内存足够(我的机器上这个值最大有19位数)
*/
int epoll_create(int size);
/*description:
*控制某个epoll文件描述符上的事件:注册、修改、删除。其中参数epfd是epoll_create()创建的
*epoll专用的文件描述符。相对于select模型中的FD_SET和FD_CLR宏
*/
int epoll_ctl(int epfd, int op, int fd, int epoll_event* event);
/*description:
*等待I/O事件发生
*params:
*epfd: 由epoll_create()生成的epoll专用的文件描述符
*epoll_event: 用于回传待处理事件的数组
*maxevents: 每次能处理的事件数
*timeout: 等待I/O事件发生的超时值
*return:
*返回事件的发生数
*/
int epoll_wait(int epfd, struct epoll_event* events, int maxevents, int timeout);