The code as is never checks the requested address family when doing a DNS query, so resolving an IPv6 only host with AddressFamily.INET would still return an IPv6.