Function resolveHost
Resolves the given host name/IP address string.
NetworkAddress resolveHost
(
string host,
std .socket .AddressFamily family = AddressFamily .UNSPEC,
bool use_dns = true,
core .time .Duration timeout = max()
) @safe;
NetworkAddress resolveHost
(
string host,
ushort family,
bool use_dns = true,
core .time .Duration timeout = max()
) @safe;
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.
Parameters
Name | Description |
---|---|
host | The string to resolve, either an IP address or a hostname |
family | 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 | 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 | If use_dns is true , the Duration to use as timeout
for the DNS lookup. |
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.
Returns
A valid NetworkAddress
matching host
.