Address

Address is an abstract class for representing a socket addresses.

Members

Functions

toAddrString
string toAddrString()

Attempts to retrieve the host address as a human-readable string.

toHostNameString
string toHostNameString()

Attempts to retrieve the host name as a fully qualified domain name.

toPortString
string toPortString()

Attempts to retrieve the numeric port number as a string.

toServiceNameString
string toServiceNameString()

Attempts to retrieve the service name as a string.

toString
string toString()

Human readable string representing this address.

Properties

addressFamily
AddressFamily addressFamily [@property getter]

Family of this address.

name
sockaddr* name [@property getter]

Returns pointer to underlying sockaddr structure.

nameLen
socklen_t nameLen [@property getter]

Returns actual size of underlying sockaddr structure.

Examples

1 writeln("About www.google.com port 80:");
2 try
3 {
4     Address[] addresses = getAddress("www.google.com", 80);
5     writefln("  %d addresses found.", addresses.length);
6     foreach (int i, Address a; addresses)
7     {
8         writefln("  Address %d:", i+1);
9         writefln("    IP address: %s", a.toAddrString());
10         writefln("    Hostname: %s", a.toHostNameString());
11         writefln("    Port: %s", a.toPortString());
12         writefln("    Service name: %s",
13             a.toServiceNameString());
14     }
15 }
16 catch (SocketException e)
17     writefln("  Lookup error: %s", e.msg);

Meta

Suggestion Box / Bug Report