Platform SDK: Windows Sockets |
If TCP/IP service provider supports IPv6 addressing, it must install itself twice:
So, WSAEnumProtocols returns two WSAPROTOCOL_INFO structures for each of the supported socket types (SOCK_STREAM, SOCK_DGRAM, SOCK_RAW). The iAddressFamily must by set to AF_INET for IPv4 addressing, and to AF_INET6 for IPv6 addressing.
The IPv6 addresses are described in the following structures:
struct sockaddr_in6 { short sin6_family; /* AF_INET6 */ u_short sin6_port; /* Transport level port number */ u_long sin6_flowinfo; /* IPv6 flow information */ struct in_addr6 sin6_addr; /* IPv6 address */ }; struct in_addr6 { u_char s6_addr[16]; /* IPv6 address */ };
If an application uses Windows Sockets 1.1 functions and wants to use IPv6 addresses, it may continue to use all the old functions that take the SOCKADDR structure as one of the parameters (bind, connect, sendto, and recvfrom, accept, and so forth). The only change that is required is to use SOCKADDR_IN6 instead of SOCKADDR.
However, the name resolution functions (gethostbyname, gethostbyaddr, and so forth) and address conversion functions (inet_addr, inet_ntoa) can not be reused because they assume an IP address 4 bytes in length. An application that wants to perform name resolution and address conversion for IPv6 addresses must use the Windows Sockets 2-specific functions (WSAStringToAddress, WSAAddressToString, and so forth).