Swoole\Coroutine\System::getaddrinfo (string $domain, int $family = AF_INET, int $socktype = SOCK_STREAM, int $protocol = IPPROTO_TCP, string $service = null)

Declaration

<?php
Swoole\Coroutine\System::getaddrinfo (string $domain, int $family = AF_INET, int $socktype = SOCK_STREAM, int $protocol = IPPROTO_TCP, string $service = null)

Parameters

Return

ip

if success, it returns the IP address, otherwise it returns FALSE.

Description

Alias: Swoole\Coroutine::getaddrinfo.

Get the IP address of a hostname.

You can also use Swoole\Coroutine\System::dnsLookup to get IP of a hostname.

Example

<?php
Co\run(function () {
    $ip = Swoole\Coroutine\System::getaddrinfo('www.google.com');
});