getAddress

Provides _protocol-independent translation from host names to socket addresses. Uses getAddressInfo if the current system supports it, and InternetHost otherwise.

  1. Address[] getAddress(const(char)[] hostname, const(char)[] service)
  2. Address[] getAddress(const(char)[] hostname, ushort port)
    @safe
    getAddress
    (
    scope const(char)[] hostname
    ,
    ushort port
    )

Return Value

Type: Address[]

Array with one Address instance per socket address.

Throws

SocketOSException on failure.

Examples

writeln("Resolving www.digitalmars.com:");
try
{
    auto addresses = getAddress("www.digitalmars.com");
    foreach (address; addresses)
        writefln("  IP: %s", address.toAddrString());
}
catch (SocketException e)
    writefln("  Lookup failed: %s", e.msg);

Meta