Are polling for error events, not just input or output events? I haven't
tried it but it might work for shutting down a socket.
If you are doing a close on a socket descriptor from one thread while it's
still being used by another thread then stop since it's extremely dangerous.
It's eqivalent to freeing the memory for a data object that's still being
used by another thread. When you close a file/socket descriptor, it's
immediately available for reuse by another thread that's creating descriptors.
So the other thread still using the old descriptor may do i/o on a completely
different socket or file depending on what the reused descriptor is actually
When you get lemons, you make lemonade.
When you get hardware, you make software.