For the latest stable version, please use Emilua API 0.10!

ip.get_address_info

Synopsis

local ip = require "ip"

ip.tcp.get_address_info()
ip.tcp.get_address_v4_info()
ip.tcp.get_address_v6_info()
ip.udp.get_address_info()
ip.udp.get_address_v4_info()
ip.udp.get_address_v6_info()

function(host: string|ip.address, service: string|integer[, flags: string[]])
    -> { address: ip.address, port: integer, canonical_name: string|nil }[]

Description

Forward-resolves host and service into a list of endpoint entries. Current fiber is suspended until operation finishes.

If no flags are passed to this function (i.e. flags is nil) then this function will follow the glibc defaults even on non-glibc systems: bit.bor(address_configured,v4_mapped).

Returns a list of entries. Each entry will be a table with the following members:

  • address: ip.address.

  • port: integer.

If "canonical_name" is passed in flags then each entry will also include:

  • canonical_name: string.

If host is an ip.address then no host name resolution should be attempted.

If service is a number then no service name resolution should be attempted.

Flags

address_configured

Only return IPv4 addresses if a non-loopback IPv4 address is configured for the system. Only return IPv6 addresses if a non-loopback IPv6 address is configured for the system.

all_matching

If used with v4_mapped, return all matching IPv6 and IPv4 addresses.

canonical_name

Determine the canonical name of the host specified in the query.

passive

Indicate that returned endpoint is intended for use as a locally bound socket endpoint.

v4_mapped

If the query protocol family is specified as IPv6, return IPv4-mapped IPv6 addresses on finding no IPv6 addresses.