I want to adapt my old C codebases, that were written for IPv4, to work with IPv6. What do I need to change so that my C code works with both IPv4 and IPv6?
Find all code that uses
ntohs, and any direct
sockaddr_in manipulation and replace it with simple calls to
getnameinfo. This will make your code much simpler and more maintainable and IPv6 will automatically work with no additional effort.