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
RWInet6Addr addr1( 3010, "net.roguewave.com" ); // 1
RWInet6Addr addr2( 3010 ); // 2
RWInet6Addr addr3( "stream:net.roguewave.com:3010" ); // 3
RWInet6Addr addr4( "stream:[fe80::2b0:d0ff:fe92:873c]:3010" ); // 4
RWInet6Addr addr5( "stream:net.roguewave.com%4:3010" ); // 5
//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.
NOTE: 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.