Constructing a Host
A host is identified by either a symbolic name, like net.roguewave.com, or by an IPv6 hex address, like fe80::2b0:d0ff:fe92:873c. A particular host can have more than one symbolic name. A host address usually has only one IPv6 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.
 
RWInet6Host host1("net.roguewave.com");
RWInet6Host host2("fe80::2b0:d0ff:fe92:873c");
 
Once a host object is constructed, you can use the member functions of RWInet6Host to determine characteristics of the host.
Example 11 prints information about a host.
Example 11 – Printing information about a host.
#include <rw/rstream.h>
#include <rw/network/RWInet6Host.h>
 
int main()
{
RWWinSockInfo winsock;
RWInet6Host host = RWInet6Host::me(); // 1
cout << host.getName() << endl; // 2
cout << RWInet6Host::addressAsString(host.getAddress()) // 3
<< endl;
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 RWInet6Host::getAddress() returns the sixteen-byte IPv6 address of the host. Usually, this address is printed in IPv6 hex address notation. The static function RWInet6Host::addressAsString converts the address from an In6_addr struct to a string in IPv6 hex address format.