resolveHost

Resolves the given host name/IP address string.

This routine converts a string to a NetworkAddress. If the string is an IP address, no network traffic will be generated and the routine will not block. If it is not, a DNS query will be issued, unless forbidden by the use_dns parameter, in which case the query is guaranteed not to block.

  1. NetworkAddress resolveHost(string host, AddressFamily family, bool use_dns, Duration timeout)
  2. NetworkAddress resolveHost(string host, ushort family, bool use_dns, Duration timeout)
    @safe
    resolveHost
    (
    string host
    ,
    ushort family
    ,
    bool use_dns = true
    ,
    Duration timeout = Duration.max
    )

Parameters

host string

The string to resolve, either an IP address or a hostname

family ushort

The desired address family to return. By default, returns the family that host is in. If a value is specified, this routine will throw if the value found for host doesn't match this parameter.

use_dns bool

Whether to use the DNS if host is not an IP address. If false and host is not an IP, this routine will throw. Defaults to true.

timeout Duration

If use_dns is true, the Duration to use as timeout for the DNS lookup.

Return Value

A valid NetworkAddress matching host.

Throws

In case of lookup failure, if family doesn't match host, or if use_dns is false but host is not an IP. See the parameter description for more details.

Meta