epoll的一个使用例子
使用到主要函数有: #include <sys/epoll.h> int epoll_create(int size); int epoll_create1(int flags); int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); typedef union epoll_data { void *ptr; int fd; uint32_t u32; uint64_t u64; } epoll_data_t; struct epoll_event { uint32_t events; /* Epoll events */ epoll_data_t data; /* User data variable */ }; 1 #define EPOLL_SIZE 1024 2 int doServiceEpoll(int listenFd) 3 { 4 struct epoll_event events[EPOLL_SIZE]; 5 6 struct epoll_event event; 7 int epollFd =