src/Viserio/Component/WebServer/Command/ServerLogCommand.php
private function getLogs($socket): ?\Generator
    {
        $sockets = [\fstat($socket)['size'] => $socket];
        $write   = [];

        while (true) {
            $read = $sockets;
            \stream_select($read, $write, $write, null);

            foreach ($read as $stream) {
                $size = \fstat($stream)['size'];

                if ($socket === $stream) {
                    $stream                 = \stream_socket_accept($socket);
                    $sockets[$size]         = $stream;
                } elseif (\feof($stream)) {
                    unset($sockets[$size]);

                    \fclose($stream);
                } else {
                    yield $size => \fgets($stream);
                }
            }
        }
    }
private function getLogs($socket): ?\Generator
    {
        $sockets = [\fstat($socket)['size'] => $socket];
        $write   = [];

        while (true) {
            $read = $sockets;
            \stream_select($read, $write, $write, null);

            foreach ($read as $stream) {
                $size = \fstat($stream)['size'];

                if ($socket === $stream) {
                    $stream                 = \stream_socket_accept($socket);
                    $sockets[$size]         = $stream;
                } elseif (\feof($stream)) {
                    unset($sockets[$size]);

                    \fclose($stream);
                } else {
                    yield $size => \fgets($stream);
                }
            }
        }
    }
Get collected logs.

@param resource $socket

@return null|\Generator