The OpenD Programming Language

Address

Abstract class for representing a socket address.

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

writeln("About www.google.com port 80:");
try
{
    Address[] addresses = getAddress("www.google.com", 80);
    writefln("  %d addresses found.", addresses.length);
    foreach (int i, Address a; addresses)
    {
        writefln("  Address %d:", i+1);
        writefln("    IP address: %s", a.toAddrString());
        writefln("    Hostname: %s", a.toHostNameString());
        writefln("    Port: %s", a.toPortString());
        writefln("    Service name: %s",
            a.toServiceNameString());
    }
}
catch (SocketException e)
    writefln("  Lookup error: %s", e.msg);

Meta