getAddrsForInterface

Iterates over IP addresses for the network interface.

Obtains the network address of the local system from getifaddrs() and calls dg with a host and service name string for each of these addresses. If host and service name string formatting failed for an address, dg is called with a null address and the status code of the conversion function, getnameinfo(). See the manpage of getnameinfo() for its status codes.

dg should return false to continue or true to stop iteration.

If dg isn't called and return value is true, getifaddrs() has failed; in this case check errno and see the getnameinfo() manpage.

  1. istring[] getAddrsForInterface(cstring interface_name, bool ipv6)
  2. bool getAddrsForInterface(cstring interface_name, bool ipv6, bool delegate(cstring address, int getnameinfo_status) dg)
    bool
    getAddrsForInterface

Parameters

interface_name cstring

Name of the interface (e.g. eth0)

ipv6 bool

true: fetch IPv6 addresses, false: IPv4

dg bool delegate

iteration delegate

Return Value

Type: bool

true if either dg returned true to stop the iteration or getifaddrs() failed or false if the iteration finished normally.

Meta