'Convert a DNS into an IP address using the Python socket module.
Thanks to Kevin Drapel.'

@staticmethod
def dnsToIp(dns):

    ips = DNSUtils.CACHE_nameToIp.get(dns)
    if (ips is not None):
        return ips
    ips = list()
    saveerr = None
    for (fam, ipfam) in ((socket.AF_INET, IPAddr.FAM_IPv4), (socket.AF_INET6, IPAddr.FAM_IPv6)):
        try:
            for result in socket.getaddrinfo(dns, None, fam, 0, socket.IPPROTO_TCP):
                ip = IPAddr(result[4][0], ipfam)
                if ip.isValid:
                    ips.append(ip)
        except socket.error as e:
            saveerr = e
    if ((not ips) and saveerr):
        logSys.warning('Unable    to    find    a    corresponding    IP    address    for    %s:    %s', dns, saveerr)
    DNSUtils.CACHE_nameToIp.set(dns, ips)
    return ips
