(注:由于前面写过select和poll函数,在epoll函数中大部分代码会和钱前面两个的函数重复,所以在下面的代码中,不再注释
重复代码,只将与之不同的代码注释,读者可以通过“https://mp.csdn.net/postedit/83215953”或者“https://blog.csdn.net/xing1584114471/article/details/83343021”、“https://blog.csdn.net/xing1584114471/article/details/83451149”了解)
头文件以及宏定义:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <string.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#define MAXFD 10