There's quite more to this than just simply replacing gethostbyname() with getaddrinfo().
That may be true most of the time for TCP/UDP client-side, but even there you'll run into OS-specific
quirks the moment you try to support more than one OS (or even more than one version of the same OS).
I've done my share of porting and here's some of the things I've ran into:
- OSs don't support all (major) RFCs, so e.g. you don't get inet_pton() or even some getaddrinfo() flags
- OSs support some draft RFC version (socklen_t mess)
- getaddrinfo() return values are system-specific (EAI_NODATA, EAI_PROTOCOL)
- getaddrinfo() with AI_ADDRCONFIG doesn't work or works differently on each system
- IPv6-mapped IPv4 addresses (don't get me started)
- server-side: IPv6 sockets cannot handle IPv4 traffic on all systems, so you end up having two separate sockets listening to the same port
- retrieving a list of local IP addresses from NICs - all ioctl()s changed, no proper documentation (except for BSDs fantastic getifaddrs(), also ported to newer Linuxes)
- if you're dealing with non-standard ports, you now have to fiddle with two sockaddr structures (_in and _in6)
- comparing two network addresses for equality is a pain in the ass - for example, one is an IPv6 address and the other is an IPv6-mapped IPv4 address
- huge piles of OS bugs (AIX being the winner here)
- xinetd/inetd configuration changes (IPv6-only, dual stack) are different for each system
- nslookup output (AAAA addresses) is different for each system
- accessing Windows network shares via IP addresses
- using IPv6 addresses with existing tools (e.g. ping -6 vs. ping6, ssh [addr]:port?)
Then there are differences in multicasting, raw sockets, addressing schemes (link-local, no broadcasting),
transition mechanisms (6to4, Teredo etc.) and so on and so forth.
IMO, porting to IPv6 is light years from being transparent.