According to the documentation, socket_read() is supposed to return FALSE when the remote host has closed the connection, and an empty string '' when there is no more data to read.  However, during my testing, it never returns FALSE, even when I close the remote host connection.  Here is the relevant code:
$data = '';
do {
    $read = socket_read($socket, 1024);
    if ($read === FALSE) {
        throw new SocketDisconnectException();
    }
    $data .= $read;
} while ($read !== '');
The SocketDisconnectException never gets thrown, even when I disconnect the remote host connection.  I've double and triple checked that I'm not catching the exception and discarding it, and even thrown in an echo and exit into the conditional as a sanity check.
Has the behavior of this function changed, or am I doing something wrong?