parseAddress

fnAddress parseAddress(scope const(char)[] hostaddr, scope const(char)[] service = null)

Provides _protocol-independent parsing of network addresses. Does not attempt name resolution. Uses getAddressInfo with AddressInfoFlags.NUMERICHOST if the current system supports it, and InternetAddress otherwise.

Returns

An Address instance representing specified address.

Throws

SocketException on failure.

Example:

writeln("Enter IP address:");
string ip = readln().chomp();
try
{
   Address address = parseAddress(ip);
   writefln("Looking up reverse of %s:",
       address.toAddrString());
   try
   {
       string reverse = address.toHostNameString();
       if (reverse)
           writefln("  Reverse name: %s", reverse);
       else
           writeln("  Reverse hostname not found.");
   }
   catch (SocketException e)
       writefln("  Lookup error: %s", e.msg);
}
catch (SocketException e)
{
   writefln("  %s is not a valid IP address: %s",
       ip, e.msg);
}

fnAddress parseAddress(scope const(char)[] hostaddr, ushort port)

ditto