class InternetAddress

Socket Address. More...

Full nameCoral::InternetAddress
Definition#include <internetaddress.h>
InheritsCoral::SocketAddress [virtual public]
Inherited byInternetFlow
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members


Detailed Description

This class manages an internet address.

InternetAddress ()

Constructor for an empty internet address.

InternetAddress (const InternetAddress& address)

Constructor for an internet address from an internet address.

Parameters:
addressInternet address.

InternetAddress (const String& address)

Constructor for a internet address given by a string. Examples: "gaffel:7500", "12.34.56.78:7500", "3ffe:4711::0!7500", "odin:7500", "ipv6-odin:7500".

Parameters:
addressAddress string.

InternetAddress (const String& hostName, const card16 port)

Constructor for a internet address given by host name and port.

Parameters:
hostNameHost name.
portPort number.

InternetAddress (const card16 port)

Constructor for INADDR_ANY address with given port.

Parameters:
portPort number.

InternetAddress (sockaddr* address, socklen_t length)

Constructor for a internet address from the system's sockaddr structure. The sockaddr structure may be sockaddr_in (IPv4) or sockaddr_in6 (IPv6).

Parameters:
addresssockaddr.
lengthLength of sockaddr (sizeof(sockaddr_in) or sizeof(sockaddr_in6)).

~InternetAddress ()

Destructor.

void reset ()

Reset internet address.

Reimplemented from SocketAddress

void init (const InternetAddress& address)

Initialize internet address from internet address.

void init (const card16 port)

Initialize internet address with INADDR_ANY and given port.

Parameters:
portPort number.

void init (const String& hostName, const card16 port)

Initialize internet address with given host name and port.

Parameters:
hostNameHost name.
portPort number.

inline InternetAddress& operator= (const InternetAddress& source)

Implementation of = operator.

inline card16 getPort ()
[const]

Get port of address.

inline void setPort (const card16 port)

Set port of address.

enum PrintFormat {PF_Address = (1 << 0), PF_Hostname = (1 << 1), PF_Full = PF_Address | PF_Hostname }

setPrintFormat() printing formats.

inline PrintFormat getPrintFormat ()
[const]

Get printing format.

Returns: Print format.

inline void setPrintFormat (const PrintFormat format)

Set printing format.

Parameters:
formatPrint format.

bool isValid ()
[const]

isValid() implementation of SocketAddress.

See also: SocketAddress#isValid

Reimplemented from SocketAddress

inline bool isNull ()
[const]

Check, if the address is null.

Returns: true, if the address is not null; false otherwise.

String getAddressString ()
[const]

Get address string.

Returns: Address string.

Reimplemented from SocketAddress

inline bool isIPv4 ()
[const]

Check, if internet address is an IPv4 or IPv4-mapped address.

Returns: true, if address is an IPv4 or IPv4-mapped address; false otherwise.

inline bool isIPv6 ()
[const]

Check, if internet address is a real (not IPv4-mapped) IPv6 address. Addresses which return true here can be used with labeled flows by class Socket.

Returns: true, if address is real IPv6; false otherwise.

InternetAddress getLocalAddress (const InternetAddress& peer)
[static]

Get the local host address. The parameter peer gives the address of the other host.

Examples: localhost => localhost address (127.0.0.1 or ::1). ethernet-host => ethernet interface address. internet-address => dynamic-ip address set by pppd.

Parameters:
addressReference to SocketAddress to write address to.
peerAddress of peer.

Returns: true, if call was successful; false otherwise.

cardinal getSystemAddress (sockaddr* buffer, const socklen_t length, const cardinal type)
[const]

getSystemAddress() implementation of SocketAddress

See also: SocketAddress#getSystemAddress

Reimplemented from SocketAddress

bool setSystemAddress (sockaddr* address, const socklen_t length)

setSystemAddress() implementation of SocketAddress.

See also: SocketAddress#setSystemAddress

Reimplemented from SocketAddress

cardinal getHostByName (const String& name, card16* myadr)
[static]

Wrapper for system's gethostbyname() function. This version does support IPv6 addresses even if the system itself does not support IPv6. IPv6 addresses are then converted to IPv4 if possible (IPv4-mapped IPv6).

Parameters:
nameHost name.
myadrStorage space to save a IPv6 address (16 bytes).
lengthLength of the address saved in myaddr or 0 in case of failure.

inline bool hasIPv6 ()
[static]

Check, if IPv6 support is available.

Returns: true, if IPv6 support is available; false otherwise.

static bool UseIPv6

Static variable which shows the availability of IPv6. Setting this variable to false on an IPv6 system simulates an IPv4-only system.

Do *not* change this variable if Socket or InternetAddress objects are already in use!!!

int operator== (const InternetAddress& address)
[const]

Implementation of == operator.

inline int operator!= (const InternetAddress& address)
[const]

Implementation of != operator.

int operator< (const InternetAddress& address)
[const]

Implementation of < operator.

inline int operator<= (const InternetAddress& address)
[const]

Implementation of <= operator.

int operator> (const InternetAddress& address)
[const]

Implementation of > operator.

inline int operator>= (const InternetAddress& address)
[const]

Implementation of >= operator.

inline PortableAddress getPortableAddress ()
[const]

Get PortableAddress from InternetAddress.

Returns: PortableAddress.

InternetAddress (const PortableAddress& address)

Constructor for InternetAddress from PortableAddress.

Parameters:
addressPortableAddress.

void init (const PortableAddress& address)

Initialize InternetAddress from PortableAddress.

Parameters:
addressPortableAddress.