[CPP] View plain copy/* user:lixiujie * date:20101207 * desc:unix (Linux) non-blocking socket communication Epoll model, multiplexing, TCP server-side, sends response information to the client. * file:tcp_server_epoll.c * system:ubuntu 64bit * gcc tcp_server_epoll.c -o tcp_server_epoll * tcp_server_epoll 7878 * epoll Function Introduction Epoll is an improved poll of the Linux kernel to handle large batches of handles and is an enhanced version of the select/poll of the multiplexed IO interface under Linux. It can significantly reduce the system CPU utilization of programs in a large number of concurrent connections with only a few active cases. epoll Advantages 1, it retains the two relative advantages of the poll with Select, 2, the parameters of the epoll_wait events as an argument, and returns directly to the Fd,epoll_ of events that occurred. The return value of wait is both the number of occurrences, and the loop operation after the return of poll is omitted. 3, no longer like Select, poll the identifier is limited to Fd,epoll can be extended to pointers, greatly increasing the flexibility under the Epoll model. epoll Usage notes 1, if the FD is registered in two Epoll, two epoll will trigger the event if there is time. 2. If the FD registered in Epoll is closed, it will automatically be cleared out of the Epoll listener list. Note: Turn off automatic cleanup without phone removal 3, if multiple events trigger Epoll at the same time, multiple events will be returned together. 4, Epoll_wait will always listen to epollhup events occur, so it does notNeed to be added to events.