protected function query(Context $context, string $server, string $host, int $type): \Generator
    {
        $response = yield $this->getUdpConnector($server)->send($context, $this->createRequest($host, $type));
        
        if ($response->isTruncated()) {
            $response = yield $this->getTcpConnector($server)->send($context, $this->createRequest($host, $type));
        }
        
        $resolved = [];
        $ttl = \PHP_INT_MAX;
        
        foreach ($response->getAnswers() as $record) {
            if ($record['type'] === $type) {
                $resolved[] = new Address($record['data']);
                $ttl = \min($ttl, $record['ttl']);
            }
        }
        
        if (empty($resolved)) {
            throw new \RuntimeException(\sprintf('Unable to resolve host "%s" into an IP using DNS server %s', $host, $server));
        }
        
        return [
            'ttl' => \max(1, \min(300, $ttl)),
            'ips' => $resolved
        ];
    }