iyasar iyasar - 1 year ago 110
C Question

Migration from IPV4 to IPV6 in C codes

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?

R.. R..
Answer Source

Find all code that uses inet_aton, inet_ntoa, gethostbyname, gethostbyaddr, htonl, htons, ntohl, ntohs, and any direct sockaddr_in manipulation and replace it with simple calls to getaddrinfo or getnameinfo. This will make your code much simpler and more maintainable and IPv6 will automatically work with no additional effort.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download