3 ms·
On Linux, a conceptually similar idea to the loopback socket could safely and efficiently be implemented with epoll(). The epoll instance itself is a poll-able
by afr0ck 5y ago
On Linux, a conceptually similar idea to the loopback socket could safely and efficiently be implemented with epoll(). The epoll instance itself is a poll-able file descriptor that can be fed to epoll() alongside the sockets.
When a new socket is added, epoll() gets triggered (by the loopback epoll file descriptor that was used to add the new socket, since it's also actively being polled by epoll). epoll() immediately returns to userspace, the event is handled (to do necessary socket bookkeeping) then go back to polling again with the updated list of sockets.