socket_addrinfo_lookup
Description
The socket_addrinfo_lookup of Sockets for PHP get array with contents of getaddrinfo about the given hostname.
Syntax
socket_addrinfo_lookup( string $host, ?string $service = null, array $hints = [] ): array|false
Parameters
host
Hostname to search.
service
The service to connect to. If service is a numeric string, it designates the port. Otherwise it designates a network service name, which is mapped to a port by the operating system.
hints
Hints provide criteria for selecting addresses returned. You may specify the hints as defined by getaddrinfo.
Return
Returns an array of AddressInfo instances that can be used with the other socket_addrinfo functions. On failure, false is returned.
Examples
1 · host
<? $host = '127.0.0.1'; $return = socket_addrinfo_lookup($host); print_r($return); ?>
Array ( [0] => AddressInfo Object ( ) [1] => AddressInfo Object ( ) [2] => AddressInfo Object ( ) )
2 · service
<? $host = '127.0.0.1'; $service = '5000'; $return = socket_addrinfo_lookup($host, $service); print_r($return); ?>
Array ( [0] => AddressInfo Object ( ) [1] => AddressInfo Object ( ) [2] => AddressInfo Object ( ) )
3 · hints
<? $host = '127.0.0.1'; $service = '5000'; $hints = [ 'ai_family' => 'AF_INET', 'ai_socktype' => 'SOCK_STREAM' ]; $return = socket_addrinfo_lookup($host, $service, $hints); print_r($return); ?>
Array ( [0] => AddressInfo Object ( ) [1] => AddressInfo Object ( ) [2] => AddressInfo Object ( ) )
Links
Sockets
- socket_accept
- socket_addrinfo_bind
- socket_addrinfo_connect
- socket_addrinfo_explain
- socket_atmark
- socket_bind
- socket_clear_error
- socket_close
- socket_cmsg_space
- socket_connect
- socket_create
- socket_create_listen
- socket_create_pair
- socket_export_stream
- socket_get_option
- socket_getopt
- socket_getpeername
- socket_getsockname
- socket_import_stream
- socket_last_error
- socket_listen
- socket_read
- socket_recv
- socket_recvfrom
- socket_recvmsg
- socket_select
- socket_send
- socket_sendmsg
- socket_sendto
- socket_set_block
- socket_set_nonblock
- socket_set_option
- socket_setopt
- socket_shutdown
- socket_strerror
- socket_write
- socket_wsaprotocol_info_export
- socket_wsaprotocol_info_import
- socket_wsaprotocol_info_release