PHP Classes

File: vendor/react/dns/examples/91-query-a-and-aaaa.php

Recommend this page to a friend!
  Classes of Stanley Aloh   Tic Tac Toe Multiplayer   vendor/react/dns/examples/91-query-a-and-aaaa.php   Download  
File: vendor/react/dns/examples/91-query-a-and-aaaa.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Tic Tac Toe Multiplayer
Manage the interactions ofTic-Tac-Toe game players
Author: By
Last change:
Date: 9 days ago
Size: 835 bytes
 

Contents

Class file image Download
<?php

use React\Dns\Model\Message;
use
React\Dns\Query\Query;
use
React\Dns\Query\UdpTransportExecutor;
use
React\EventLoop\Factory;

require
__DIR__ . '/../vendor/autoload.php';

$loop = Factory::create();
$executor = new UdpTransportExecutor('8.8.8.8:53', $loop);

$name = isset($argv[1]) ? $argv[1] : 'www.google.com';

$ipv4Query = new Query($name, Message::TYPE_A, Message::CLASS_IN);
$ipv6Query = new Query($name, Message::TYPE_AAAA, Message::CLASS_IN);

$executor->query($ipv4Query)->then(function (Message $message) {
    foreach (
$message->answers as $answer) {
        echo
'IPv4: ' . $answer->data . PHP_EOL;
    }
},
'printf');
$executor->query($ipv6Query)->then(function (Message $message) {
    foreach (
$message->answers as $answer) {
        echo
'IPv6: ' . $answer->data . PHP_EOL;
    }
},
'printf');

$loop->run();