Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Networking Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

6.6 Using IPv6 Addresses

IPv6 addresses represent the next generation of IP addresses. Like internet (IPv4) addresses before them, these addresses identify communication endpoints on an internet. IPv6 differs from IPv4 in the number of addressable endpoints that it can support, as well as a number of additional features that are outside of the scope of the Essential Networking Module User's Guide.

An IPv6 address is composed of three parts:

An IPv6 address is represented in the Networking package as an RWInet6Addr. As shown in Figure 11, an RWInet6Addr object contains two objects, an RWInet6Host to represent the host, and an RWInetPort to represent the port.

Figure 11: An RWInet6Addr object

6.6.1 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.

Once a host object is constructed, you can use the member functions of RWInet6Host to determine characteristics of the host. For more information about RWInet6Host, see its class descriptin in the SourcePro C++ API Reference Guide.

Example 11 prints information about a host.

Example 11: Printing information about a host.

//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.

6.6.2 Building IPv6 Addresses

Example 12 shows how to build an IPv6 address object by specifying the port and then the host.

Example 12: Building IPv6 addresses

//1

Includes both a port and a host. Automatic type conversion turns the integer 3010 into an RWInetPort, and turns the string into an RWInet6Host.

//2

When the host name is omitted, the special host ANY is used. This address connects to any available IPv6 address on the current computer.

//3

Constructs the address from a string. The format is the socket type (stream or dgram) followed by the host identifier, followed by the scope, followed by a port identifier. The fields are separated by colons. You can omit the socket type, host, and scope, which means that net.roguewave.com:3010 and 3010 are allowed. The default socket type is stream. If only the port number is used, the host defaults to ANY.

//4

In order to distinguish an IPv6 hex address from the rest of an address string, square brackets ('[' and ']') are added around the hex address to distinguish it from the other fields.

//5

This string construction includes the specification of a scope ID. The scope ID field is optional on most platforms, however some platforms require a scope ID in order to resolve the Network Interface that should be used.


IPv6 addresses are not supported on all platforms. To verify that IPv6 addresses are supported by Rogue Wave on your platform, check if the RWNET_HAS_INET6_SOCKETS macro is defined.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.