src/Datagram/BasicDatagram.php
public function receive(int $length = 0, float $timeout = 0): \Generator
    {
        while (!$this->readQueue->isEmpty()) {
            /** @var \Icicle\Awaitable\Delayed $delayed */
            $delayed = $this->readQueue->bottom();
            yield $delayed; // Wait for previous read to complete.
        }
        
        if (!$this->isOpen()) {
            throw new UnavailableException('The datagram is no longer readable.');
        }

        $this->length = (int) $length;
        if (0 > $this->length) {
            throw new InvalidArgumentError('The length must be a non-negative integer.');
        } elseif (0 === $this->length) {
            $this->length = self::MAX_PACKET_SIZE;
        }

        $this->readQueue->push($delayed = new Delayed($this->onReceiveCancelled));
        $this->poll->listen($timeout);

        return yield $delayed;
    }
public function receive(int $length = 0, float $timeout = 0): \Generator
    {
        while (!$this->readQueue->isEmpty()) {
            /** @var \Icicle\Awaitable\Delayed $delayed */
            $delayed = $this->readQueue->bottom();
            yield $delayed; // Wait for previous read to complete.
        }
        
        if (!$this->isOpen()) {
            throw new UnavailableException('The datagram is no longer readable.');
        }

        $this->length = (int) $length;
        if (0 > $this->length) {
            throw new InvalidArgumentError('The length must be a non-negative integer.');
        } elseif (0 === $this->length) {
            $this->length = self::MAX_PACKET_SIZE;
        }

        $this->readQueue->push($delayed = new Delayed($this->onReceiveCancelled));
        $this->poll->listen($timeout);

        return yield $delayed;
    }
{@inheritdoc}