PHP Classes

File: vendor/react/dns/examples/02-concurrent.php

Recommend this page to a friend!
  Classes of Stanley Aloh   Tic Tac Toe Multiplayer   vendor/react/dns/examples/02-concurrent.php   Download  
File: vendor/react/dns/examples/02-concurrent.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: 651 bytes
 

Contents

Class file image Download
<?php

use React\Dns\Config\Config;
use
React\Dns\Resolver\Factory;

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

$loop = React\EventLoop\Factory::create();

$config = Config::loadSystemConfigBlocking();
$server = $config->nameservers ? reset($config->nameservers) : '8.8.8.8';

$factory = new Factory();
$resolver = $factory->create($server, $loop);

$names = array_slice($argv, 1);
if (!
$names) {
   
$names = array('google.com', 'www.google.com', 'gmail.com');
}

foreach (
$names as $name) {
   
$resolver->resolve($name)->then(function ($ip) use ($name) {
        echo
'IP for ' . $name . ': ' . $ip . PHP_EOL;
    },
'printf');
}

$loop->run();