protected function parseAnswer(Context $context, Response $response): \Generator
    {
        $host = yield from $this->readLabel($context);
        
        $answer = \unpack('ntype/nclass/Nttl/nlen', yield $this->stream->readBuffer($context, 10));
        $this->offset += 10;
        
        $ttl = $answer['ttl'];
        $len = $answer['len'];
        
        // Discard payloads of truncated messages.
        if ($response->isTruncated()) {
            $data = yield $this->stream->readBuffer($context, $len);
            $this->offset += $len;
            
            return;
        }
        
        switch ($answer['type']) {
            case Message::TYPE_A:
            case Message::TYPE_AAAA:
                $data = \inet_ntop(yield $this->stream->readBuffer($context, $len));
                $this->offset += $len;
                break;
            case Message::TYPE_CNAME:
                $data = yield from $this->readLabel($context);
                break;
            default:
                $data = yield $this->stream->readBuffer($context, $len);
                $this->offset += $len;
        }
        
        if ($ttl & 0x80000000) {
            $ttl = ($ttl - 0xFFFFFFFF);
        }
        
        $response->addAnswer($host, $answer['type'], $answer['class'], $data, $ttl);
    }
protected function parseAnswer(Context $context, Response $response): \Generator
    {
        $host = yield from $this->readLabel($context);
        
        $answer = \unpack('ntype/nclass/Nttl/nlen', yield $this->stream->readBuffer($context, 10));
        $this->offset += 10;
        
        $ttl = $answer['ttl'];
        $len = $answer['len'];
        
        // Discard payloads of truncated messages.
        if ($response->isTruncated()) {
            $data = yield $this->stream->readBuffer($context, $len);
            $this->offset += $len;
            
            return;
        }
        
        switch ($answer['type']) {
            case Message::TYPE_A:
            case Message::TYPE_AAAA:
                $data = \inet_ntop(yield $this->stream->readBuffer($context, $len));
                $this->offset += $len;
                break;
            case Message::TYPE_CNAME:
                $data = yield from $this->readLabel($context);
                break;
            default:
                $data = yield $this->stream->readBuffer($context, $len);
                $this->offset += $len;
        }
        
        if ($ttl & 0x80000000) {
            $ttl = ($ttl - 0xFFFFFFFF);
        }
        
        $response->addAnswer($host, $answer['type'], $answer['class'], $data, $ttl);
    }
protected function parseAnswer ( Context $ context , Response $ response ) : \ Generator { $ host = yield from $ this -> readLabel ( $ context ) ; $ answer = \ unpack ( 'ntype/nclass/Nttl/nlen' , yield $ this -> stream -> readBuffer ( $ context , 10 ) ) ; $ this -> offset += 10 ; $ ttl = $ answer [ 'ttl' ] ; $ len = $ answer [ 'len' ] ; // Discard payloads of truncated messages. if ( $ response -> isTruncated ( ) ) { $ data = yield $ this -> stream -> readBuffer ( $ context , $ len ) ; $ this -> offset += $ len ; return ; } switch ( $ answer [ 'type' ] ) { case Message :: TYPE_A : case Message :: TYPE_AAAA : $ data = \ inet_ntop ( yield $ this -> stream -> readBuffer ( $ context , $ len ) ) ; $ this -> offset += $ len ; break ; case Message :: TYPE_CNAME : $ data = yield from $ this -> readLabel ( $ context ) ; break ; default : $ data = yield $ this -> stream -> readBuffer ( $ context , $ len ) ; $ this -> offset += $ len ; } if ( $ ttl & 0x80000000 ) { $ ttl = ( $ ttl - 0xFFFFFFFF ) ; } $ response -> addAnswer ( $ host , $ answer [ 'type' ] , $ answer [ 'class' ] , $ data , $ ttl ) ; }
Parse a DNS answer record and add it to the given response.

@param Context $context Async execution context.
@param Response $response DNS response object.
Parse a DNS answer record and add it to the given response .