The socket API is managed by the IETF RFC and must be the same on all platforms, including Windows WRT IPv6.
For IPv4 / IPv6 applications, this is ALL about getaddrinfo() and getnameinfo() . getaddrinfo - genius - examines DNS, port names, and client capabilities to solve the eternal question "can I use IPv4, IPv6, or both to reach a specific destination?" Or, if you are following the double-stack path and want it to return IPv4 IPv4 addresses, it will also do this.
It provides a direct sockaddr * structure that can be connected to bind() , recvfrom() , sendto() and the address family for socket() ... In many cases, this means that the messy sockaddr_in(6) structures are populated and have business with.
For UDP implementations, I would be careful about setting up sockets with two stacks or, more generally, binding to all interfaces ( INADDR_ANY ). The classic problem is that when addresses are not blocked (see bind() ) for certain interfaces, and the system has several interface requests, responses can go from different addresses for computers with multiple addresses based on the whims of the OS routing table, confusing application protocols , especially any systems with authentication requirements.
For implementations of UDP where this is not a problem, or TCP, dual stack sockets can save a lot of time when IPv * changes your system. Care must be taken not to rely entirely on the dual stack, where this is not entirely necessary, since there is no shortage of reasonable platforms (Old Linux, BSD, Windows 2003) deployed with IPv6 stacks that are not capable of dual socket sockets.
Einstein Feb 11 '10 at 19:57 2010-02-11 19:57
source share