How can I tell whether or not a socket has dropped its connection? I know it can be done, since many programs (ex: telnet) will immediately display a message when the collection is closed, but I cannot figure out how to do it.
PHP Code:
while(/* SocketState(t) == SOCKET_CONNECTED :P something like this? */)
    {
    }