Encapsulates an Internet host IP address and its names.
More...
#include <rw/network/RWInetHost.h>
|
(Note that these are not member symbols.)
|
std::ostream & | operator<< (std::ostream &strm, const RWInetHost &host) |
|
Encapsulates an Internet host IP address and its names. You can construct an RWInetHost from either an IP address or a symbolic name.
- Note
- Typically, Winsock implementations do not return a default alias. As a result, an RWInetHost object on a Windows platform includes alias names only if they have been explicitly defined.
◆ NameLookup
Attributes to change name lookup behavior.
Enumerator |
---|
numeric | If the host address is already known, a lookup will not be used to discover the host name. The dotted decimal form of the host address will be used as the host name.
|
◆ RWInetHost() [1/4]
RWInetHost::RWInetHost |
( |
| ) |
|
An Internet host can be specified as an actual address or through a string. The string can be either the symbolic name of the host or an IP address in dotted decimal notation. If an IP address is passed in as a long
, it must be in network byte order. The default constructor creates a special host that represents an unspecified IP address on the current machine. This is useful when constructing servers. The RWCString should contain 7-bit US-ASCII data.
◆ RWInetHost() [2/4]
RWInetHost::RWInetHost |
( |
unsigned long | IPAddress | ) |
|
An Internet host can be specified as an actual address or through a string. The string can be either the symbolic name of the host or an IP address in dotted decimal notation. If an IP address is passed in as a long
, it must be in network byte order. The default constructor creates a special host that represents an unspecified IP address on the current machine. This is useful when constructing servers. The RWCString should contain 7-bit US-ASCII data.
◆ RWInetHost() [3/4]
RWInetHost::RWInetHost |
( |
const RWCString & | hostname | ) |
|
An Internet host can be specified as an actual address or through a string. The string can be either the symbolic name of the host or an IP address in dotted decimal notation. If an IP address is passed in as a long
, it must be in network byte order. The default constructor creates a special host that represents an unspecified IP address on the current machine. This is useful when constructing servers. The RWCString should contain 7-bit US-ASCII data.
◆ RWInetHost() [4/4]
RWInetHost::RWInetHost |
( |
const char * | | ) |
|
An Internet host can be specified as an actual address or through a string. The string can be either the symbolic name of the host or an IP address in dotted decimal notation. If an IP address is passed in as a long
, it must be in network byte order. The default constructor creates a special host that represents an unspecified IP address on the current machine. This is useful when constructing servers. The RWCString should contain 7-bit US-ASCII data.
◆ addressAsString()
static RWCString RWInetHost::addressAsString |
( |
unsigned long | IPAddress | ) |
|
|
static |
Takes an address in network byte order and returns the dotted decimal string representation of the address. To go from a dotted decimal string to an address, build an RWInetHost object from the dotted decimal string. The RWCString should contain 7-bit US-ASCII data.
◆ getAddress()
unsigned long RWInetHost::getAddress |
( |
| ) |
const |
Returns the primary IP address for this host entry in network byte order. If you want to print out an IP address, use the addressAsString() static member function.
◆ getAddresses()
RWTValVector< unsigned long > RWInetHost::getAddresses |
( |
| ) |
const |
Returns a list of addresses for this host entry. Addresses are returned in network byte order. If you want to print out an IP address, use the addressAsString() static member function. The primary address is the first entry in the getAddresses() array. This call may block if prepare() has not been called.
◆ getAliases()
Returns the list of aliases for this host entry. The official name is not included in the list of aliases. This call may block if prepare() has not been called. The RWCString should contain 7-bit US-ASCII data.
- Note
- Aliases are returned only if the RWInetHost was constructed with a hostname (as opposed to an IP Address). If the class was constructed with an IP address, no aliases are fetched.
◆ getName()
Returns the official name for this host entry. This call may block if prepare() has not been called. The RWCString should contain 7-bit US-ASCII data.
◆ id()
RWCString RWInetHost::id |
( |
unsigned | level = 0 | ) |
const |
Returns a string describing self. The verbosity of the output is controlled by level, where level=0
is the most basic output, and level=9
is the most verbose. If not specified, a default value of 0 is used and is guaranteed not to block.
Depending on the level and the constructor the instance was instantiated with, the output may contain the host name or IP address, any known aliases for that name and any alternate IP addresses.
Grammar Definitions
ip-address ::= <ip address in dotted decimal notation>
ip-address-list ::= ip-address ("," ip-address)*
hostname ::= <domain name>
host ::= hostname | ip-address
alias-list ::= "(" hostname ("," hostname)* ")"
level | Calls prepare() | Output Grammar | Sample Output for id(level) given RWInetHost("127.0.0.1") |
0 | | host | 127.0.0.1 |
1 | | host | 127.0.0.1 |
2 | | host | 127.0.0.1 |
3 | X | host | localhost |
4 | X | host "(" ip-address ")" | localhost(127.0.0.1) |
5 | X | host "(" ip-address ")" | localhost(127.0.0.1) |
6 | X | host | localhost |
7 | X | host "(" ip-address ")" | localhost(127.0.0.1) |
8 | X | host "(" ip-address ")" | localhost(127.0.0.1) |
9 | X | host (alias-list)? "(" ip-address-list ")" | localhost(127.0.0.1) |
◆ me()
Returns the host object for the host on which this program is currently running.
◆ operator!=()
bool RWInetHost::operator!= |
( |
const RWInetHost & | rhs | ) |
const |
Returns true
if the two host objects are not equal.
◆ operator==()
bool RWInetHost::operator== |
( |
const RWInetHost & | rhs | ) |
const |
Returns true
if the two host objects are equal.
◆ prepare() [1/2]
void RWInetHost::prepare |
( |
| ) |
const |
Ensures that no future operations block. The prepare() function calls the host database routines to gather information about this host. It is not necessary to explicitly call prepare() because it is called by other member functions if needed. No exceptions are thrown by prepare().
◆ prepare() [2/2]
void RWInetHost::prepare |
( |
NameLookup | lookup | ) |
const |
Ensures that no future operations block. The prepare() function calls the host database routines to gather information about this host. It is not necessary to explicitly call prepare() because it is called by other member functions if needed. No exceptions are thrown by prepare().
◆ operator<<()
std::ostream & operator<< |
( |
std::ostream & | strm, |
|
|
const RWInetHost & | host ) |
|
related |
Outputs a representation of host on strm. The representation is generated using the member function host.id() with level=0
.
- Note
- This class does not have an extraction (>>) operator.