Constructing a Host
A host is identified by either a symbolic name, like net.roguewave.com, or by an Internet Protocol (IP) address, like 198.68.9.6. A particular host can have more than one symbolic name. A host address usually has only one IP address, although it is possible for a host to have more than one address.
You can construct a host object by specifying either the IP address or host name as a string, as shown in the following examples.
 
RWInetHost host1("net.roguewave.com");
RWInetHost host2("198.68.9.6");
Once a host object is constructed, you can use the member functions of RWInetHost to determine characteristics of the host.
Example 9 prints information about a host.
Example 9 – Printing information about a host
#include <rw/rstream.h>
#include <rw/network/RWInetAddr.h>
 
int main()
{
RWWinSockInfo info;
RWInetHost host = RWInetHost::me(); //1
cout << host.getName() << endl; //2
cout << RWInetHost::addressAsString(host.getAddress())
<< endl; //3
return 0;
}
//1 Returns a host object representing the host on which the program is running.
//2 Prints the primary symbolic name of the host.
//3 RWInetHost::getAddress() returns the four-byte IP address of the host. Usually, this address is printed a byte at a time using dotted decimal notation. The static function RWInetHost::addressAsString converts the address from a long integer to a string in dotted decimal format.