Special IPv6 addresses

IPv4 provides two IP addresses that have the following special meaning in the context of socket programs:
  • The Loopback Address, typically 127.0.0.1, allows applications to connect() to or send datagrams to other applications on the same host.
  • The INADDR_ANY address (0.0.0.0) allows TCP/IP server applications that specify it on a bind() call to accept incoming connections or datagrams across any network interface configured on the local host.
The concept of these special IPv4 addresses is also available in IPv6. The changes are described in Table 1.
Table 1. Special IPv6 address changes
Socket API calls Required changes
Binding a socket to the IPv4 wildcard address (INADDR_ANY - 0.0.0.0) Specify the unspecified IPv6 address (in6addr_any), (::), in the sockaddr_in6 structure.
Using LOOPBACK (127.0.0.1) on bind(), connect(), sendto(), sendmsg() Specify IPv6 Loopback address (::1) in the sockaddr_in6 structure.

See Basic socket API extensions for IPv6 for details about any constant definitions available for these special IPv6 addresses and the socket API that you are using.