public function __construct($stream, LoopInterface $loop)
{
if (!is_resource($stream) || get_resource_type($stream) !== "stream") {
throw new \InvalidArgumentException('First parameter must be a valid stream resource');
}
$this->stream = $stream;
$this->loop = $loop;
}