TCP/IP Programming Manual

2 Porting and Developing IPv6 Applications (NonStop
TCP/IPv6 and CIP Only)
This section explains how to write Guardian socket applications for IPv4 and IPv6 communications.
Topics include:
Using AF_INET6-Type Guardian Sockets for IPv6 Communications
Using AF_INET6 Guardian Sockets for IPv4 Communications (page 50)
Using AF_INET6 Guardian Sockets to Receive Messages (page 51)
Address-Testing Macros (page 52)
Porting Applications to Use AF_INET6 Sockets (page 53)
Multicast Changes for IPv6 (page 59)
Using AF_INET6-Type Guardian Sockets for IPv6 Communications
You can use AF_INET6-type Guardian sockets for IPv6 communication as well as for IPv4
communication. Table 7 (page 53) shows the sequence of events for a client application that uses
an AF_INET6-type Guardian socket to send IPv6 packets.
Figure 2 Using AF_INET6 Sockets for IPv6 Communications
1. Application calls getaddrinfo and passes the hostname (host1), the AF_INET6 address family
hint, and the AI_ADDRCONFIG flag hints. The flag hints tell the function that if an IPv6 address
is found for host1, return it. See addrinfo for a description of hints fields and values.
2. The search finds an IPv6 address for host1 in the hosts database, and getaddrinfo returns the
IPv6 address 3ffe:1200::a00:2bff:fe2d:02b2 in one or more structures of type addrinfo.
Using AF_INET6-Type Guardian Sockets for IPv6 Communications 49