Main Page Modules Namespaces C++ Classes Compound List File List Index
TNL: TNL::Address Struct Reference

# TNL::Address Struct Reference

`#include <tnlUDP.h>`

## Detailed Description

Representation of a network address.

## Public Types

enum | NamedAddress { None, Localhost, Broadcast, Any
}
| Constants specify. More...

## Public Member Functions

| Address (TransportProtocol type=IPProtocol, NamedAddress name=Any, U16 port=0)
| Constructs an address using a protocol, named address type and port.
| Address (const char *string)
| Constructs an address from a string, of the form "transport:address:port" where transport is one of ip, ipx, or (in the future) ipv6.
| Address (const IPAddress &theAddress)
| Constructs an address from an IP address.
bool | set (const char *string)
| Sets the address to the specified string, returning true if the string was a valid address.
void | set (const IPAddress &address)
| Sets the address to the specified IPAddress.
const char * | toString () const
| returns the formatted string corresponding to the address.
bool | operator== (const Address &theAddress) const
| returns true if theAddress is equal to this.
bool | operator!= (const Address &theAddress) const
| returns true if theAddress is not equal to this.
bool | isEqualAddress (const Address &theAddress) const
| returns true if the addresses are equal, not including the port.
U32 | hash () const
| Returns a 32-bit hash of this network address.
IPAddress | toIPAddress () const
| Returns a packed IPAddress of this address.

## Data Fields

U16 | transport
| One of: IPXAddress, IPAddress.
U16 | port
| For IP: sin_port For IPX: sa_socket
U32 | netNum [4]
| Address data, sized for future IPv6 usage.

## Member Enumeration Documentation

enum TNL::Address::NamedAddress

Constants specify.

Enumerator:

  None |
  Localhost |
  Broadcast |
  Any |

## Constructor & Destructor Documentation

TNL::Address::Address | ( | TransportProtocol | type = `IPProtocol`,
|  | NamedAddress | name = `Any`,
|  | U16 | port = `0` |
| ) |  |  |

Constructs an address using a protocol, named address type and port.

TNL::Address::Address | ( | const char * | string | ) | `[inline]`

Constructs an address from a string, of the form "transport:address:port" where transport is one of ip, ipx, or (in the future) ipv6.

TNL::Address::Address | ( | const IPAddress & | theAddress | ) | `[inline]`

Constructs an address from an IP address.

## Member Function Documentation

bool TNL::Address::set | ( | const char * | string | ) |

Sets the address to the specified string, returning true if the string was a valid address.

Note that this call may block if the address portion of the string requires a DNS lookup.

void TNL::Address::set | ( | const IPAddress & | address | ) |

Sets the address to the specified IPAddress.

const char* TNL::Address::toString | ( |  | ) | const

returns the formatted string corresponding to the address.

bool TNL::Address::operator== | ( | const Address & | theAddress | ) | const

returns true if theAddress is equal to this.

bool TNL::Address::operator!= | ( | const Address & | theAddress | ) | const`[inline]`

returns true if theAddress is not equal to this.

bool TNL::Address::isEqualAddress | ( | const Address & | theAddress | ) | const`[inline]`

returns true if the addresses are equal, not including the port.

U32 TNL::Address::hash | ( |  | ) | const`[inline]`

Returns a 32-bit hash of this network address.

IPAddress TNL::Address::toIPAddress | ( |  | ) | const

Returns a packed IPAddress of this address.

## Field Documentation

U16 TNL::Address::transport

One of: IPXAddress, IPAddress.

U16 TNL::Address::port

For IP: sin_port For IPX: sa_socket

U32 TNL::Address::netNum[4]

Address data, sized for future IPv6 usage.