IPv6 Programming in 5 minutes in IPv6Style
Use DNS record to check dual stack:
Try accessing the IPv6 address written in the AAAA record.
If an attempt to connect using IPv6 fails, try accessing the IPv4 address written in the A record. Use address family independent function: getaddrinfo()