Aaron's reply is, I'm afraid, pretty much incorrect. Yes, UI changes will be necessary, but any code using the traditional socket APIs is also likely to need substantial changes to support IPv6.
Most older code uses a specific "address family" constant (AF_INET
) and a particular data structure (struct sockaddr_in
). Any code still using that is effectively stuck in IPv4 land.
Newer code should use modern API calls such as getaddrinfo()
which is capable of returning the right values for protocol, address family (i.e. AF_INET6
), address, etc, regardless of whether the remote host uses IPv4 or IPv6 (or both).
It's a bit lengthy, but here's a code sample from the Linux man page for getaddrinfo
. Note how the call gets a whole list of potential remote addresses, and tries each in turn until it succeeds:
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */
hints.ai_flags = 0;
hints.ai_protocol = 0; /* Any protocol */
s = getaddrinfo(hostname, service, &hints, &result);
if (s != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(s));
exit(EXIT_FAILURE);
}
/* getaddrinfo() returns a list of address structures.
Try each address until we successfully connect(2).
If socket(2) (or connect(2)) fails, we (close the socket
and) try the next address. */
for (rp = result; rp != NULL; rp = rp->ai_next) {
sfd = socket(rp->ai_family, rp->ai_socktype,
rp->ai_protocol);
if (sfd == -1)
continue;
if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1)
break; /* Success */
close(sfd);
}
if (rp == NULL) { /* No address succeeded */
fprintf(stderr, "Could not connect\n");
exit(EXIT_FAILURE);
}
freeaddrinfo(result); /* No longer needed */