/** * Creates a valid selection key or throws an exception. An * exception will be thrown if the stream is blocking or closed; * the interest ops are invalid or the attachment is present * and not an object. * * @param MioStream $stream * @param int $interest_ops * @param Object $attachment * @throws MioException */ public function __construct($stream, $interest_ops, $attachment = null) { if ($stream->isBlocking()) { throw new MioBlockingException("Stream must be in non-blocking mode to be registered"); } if (!$stream->isOpen()) { throw new MioClosedException("Stream must be open to be registered"); } $this->stream = $stream; $this->setInterestOps($interest_ops); $this->attach($attachment); }