/** * Write a frame to this channel synchronously. * * @param OutgoingFrame $frame The frame to write. * * @throws ChannelClosedException The channel has been closed. */ public function writeSync(OutgoingFrame $frame) { if ($this->stream === null) { throw ChannelClosedException::channelClosed(); } $buffer = $this->serializer->serialize($frame); assert(Debug::dumpOutgoingFrame('#' . (int) $this->stream, $frame)); assert(Debug::dumpOutgoingHex('#' . (int) $this->stream, $buffer)); do { $bytes = @\fwrite($this->stream, $buffer); // @codeCoverageIgnoreStart if ($bytes === false) { $error = \error_get_last(); throw new ErrorException($error['message'], $error['type'], 1, $error['file'], $error['line']); } // @codeCoverageIgnoreEnd $buffer = \substr($buffer, $bytes); } while ($buffer); $this->hasSentFrame = true; }