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
        ];
    }
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
        ];
    }
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 ] ; }
Lookup IP addresses using DNS server.

@param Context $context Async execution context.
@param string $server DNS server adress.
@param string $host Host name to be resolved.
@param int $type Question type (A or AAAA).
@return array Resolved IP addresses.

@throws \RuntimeException When no IP address could be resolved.
Lookup IP addresses using DNS server .