thread_safe_check t pre ~timeout checks the file descriptors in pre for their
status and returns when at least one is available, or the timeout passes.
Sockets have a phantom type parameter that tracks the state of the socket
in order to eliminate certain errors in which socket functions are called
in the wrong order.