🧑💻 사용자 프로세스 (Node.js / Nginx 등)
// 1. epoll 인스턴스 생성
int epfd = epoll_create1(0);
// 2. 감시할 소켓 등록
epoll_ctl(epfd, EPOLL_CTL_ADD, sock1, &ev1);
epoll_ctl(epfd, EPOLL_CTL_ADD, sock2, &ev2);
epoll_ctl(epfd, EPOLL_CTL_ADD, sock3, &ev3);
// 3. 준비된 이벤트 대기 (블로킹)
int n = epoll_wait(epfd, events, 64, -1);
// 4. 준비된 fd만 처리
for (int i = 0; i < n; i++) {
handle(events[i].data.fd);
}
🌐 네트워크 (외부)
sock1 (fd=4)
sock2 (fd=5)
sock3 (fd=6)