12. refine our app to
support ipv6 and ipv4
grep -re “gethostby” *
grep -re “inet_ntoa” *
grep -re “inet_aton” *
grep -re “AF_INET” *
grep -re “sockaddr_in” *
13. special case
if our environment support ipv4 and ipv6, so
server is simple
ipv4 -> ipv4 socket
ipv6 -> ipv6 socket
const int on = 1;
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
&on, sizeof(on));
14. special case
if our environment support ipv4 and ipv6, so
client must consider priority of DNS
conversions and retry connection.
15. special case
but......
if our environment is ipv4 only, we should
use hints.ai_family = AF_INET on
getaddrinfo.
relatively, env is ipv6 only, please enable
hints.ai_family = AF_INET6 on getaddrinfo.