private function selectConnections(&$readSockets, int $timeout): void
    {
        // stream_select will not always preserve array keys
        // call it with a (deep) copy so the original is preserved
        $read = [];
        foreach ($readSockets as $id => $socket) {
            $read[] = $socket;
        }
        $writeSockets = $exceptSockets = [];

        if (false === @stream_select($read, $writeSockets, $exceptSockets, $timeout)) {
            $error = error_get_last();

            if (false === stripos($error['message'], 'interrupted system call')) {
                throw new \RuntimeException('stream_select failed: '.$error['message']);
            }

            $readSockets = [];
        } else {
            $res = [];
            foreach($read as $socket) {
                $res[array_search($socket, $readSockets)] = $socket;
            }
            $readSockets = $res;
        }
    }
private function selectConnections(&$readSockets, int $timeout): void
    {
        // stream_select will not always preserve array keys
        // call it with a (deep) copy so the original is preserved
        $read = [];
        foreach ($readSockets as $id => $socket) {
            $read[] = $socket;
        }
        $writeSockets = $exceptSockets = [];

        if (false === @stream_select($read, $writeSockets, $exceptSockets, $timeout)) {
            $error = error_get_last();

            if (false === stripos($error['message'], 'interrupted system call')) {
                throw new \RuntimeException('stream_select failed: '.$error['message']);
            }

            $readSockets = [];
        } else {
            $res = [];
            foreach($read as $socket) {
                $res[array_search($socket, $readSockets)] = $socket;
            }
            $readSockets = $res;
        }
    }
private function selectConnections ( & $ readSockets , int $ timeout ) : void { // stream_select will not always preserve array keys // call it with a (deep) copy so the original is preserved $ read = [ ] ; foreach ( $ readSockets as $ id => $ socket ) { $ read [ ] = $ socket ; } $ writeSockets = $ exceptSockets = [ ] ; if ( false === @ stream_select ( $ read , $ writeSockets , $ exceptSockets , $ timeout ) ) { $ error = error_get_last ( ) ; if ( false === stripos ( $ error [ 'message' ] , 'interrupted system call' ) ) { throw new \ RuntimeException ( 'stream_select failed: ' . $ error [ 'message' ] ) ; } $ readSockets = [ ] ; } else { $ res = [ ] ; foreach ( $ read as $ socket ) { $ res [ array_search ( $ socket , $ readSockets ) ] = $ socket ; } $ readSockets = $ res ; } }
Uses the stream select function to eliminate all non-readable sockets
from the read sockets parameter.

@param resource[] $readSockets The sockets to test for readability (output parameter)
@param int        $timeout     The stream select call timeout
Uses the stream select function to eliminate all non - readable sockets from the read sockets parameter .