Sometimes it’s impossible to forbid users from calling close themselves. For this reason it’s hard to build correct thin abstraction layers on top of epoll.
Man, this is the leakiest abstraction.
I happen to like using kqueue, and I’ve definitely written code which absolutely depends on close -> unregister. It could probably be dealt with, but certainly annoying.
I actually tried it with code you wrote, never finished it because it was really bad.
I think i stopped when i realized that i cant really close the sockets and then replaced the close calls with shutdown to close them later somewhere.
I was wondering about batch syscall interface and possible use instead of poll/epoll. If one could ask system to do one of a bunch of system calls. Then the calls could be reads and writes with the same buffer used.