<?php
Swoole\Coroutine\System::dnsLookup (string $host, float $timeout)
Hostname to lookup
Timeout of the DNS lookup
if success, it returns the IP address, otherwise it returns FALSE.
Alias: Swoole\Coroutine::dnsLookup
.
Get the IP address of a hostname.
You can also use Swoole\Coroutine::gethostbyname
to get IP of a hostname.
DNS lookup is using the DNS in /etc/resolve.conf
.
Only IPv4 is supported.
The error details can accessed by using swoole_last_error()
.
<?php
Co::set(['dns_server' => '192.0.0.1:53']);
Co\run(function () {
$ip = Swoole\Coroutine\System::dnsLookup('www.google.com', 0.5);
});