Attempts a forward lookup via the socket library and if
           successful will try to do a reverse lookup to verify DNS
           is returning both lookups.
5345
def validate(self, value):
        
        if '.' not in value:
            self.error_message = '%s is not a fully qualified domain name.' % \
                                 value
            return False
        try:
            ipaddress = socket.gethostbyname(value)
        except socket.gaierror:
            self.error_message = '%s does not resolve.' % value
            return False
        try:
            socket.gethostbyaddr(ipaddress)
        except socket.herror:
            self.error_message = \
                '%s reverse address (%s) does not resolve.' % \
                (value, ipaddress)
            return False
        self._choice = value
        return True
193152
async def _detect_proxy(self):
        '''
        '''
        if self.protocol is SOCKS4a:
            remote_address = NetAddress('www.apple.com', 80)
        else:
            remote_address = NetAddress('8.8.8.8', 53)

        sock = await self._connect_one(remote_address)
        if isinstance(sock, socket.socket):
            sock.close()
            return True

        # SOCKSFailure indicates something failed, but that we are likely talking to a
        # proxy
        return isinstance(sock, SOCKSFailure)
944656
def get_client_sock(addr):
    ""
    s = _socket.create_connection(addr)
    s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, True)
    s.setblocking(False)
    return s
130139
def lookup(self, ip_address):
        """"""

        # Is this already in our cache
        if self.ip_lookup_cache.get(ip_address):
            domain = self.ip_lookup_cache.get(ip_address)

        # Is the ip_address local or special
        elif not self.lookup_internal and net_utils.is_internal(ip_address):
            domain = 'internal'
        elif net_utils.is_special(ip_address):
            domain = net_utils.is_special(ip_address)

        # Look it up at this point
        else:
            domain = self._reverse_dns_lookup(ip_address)

        # Cache it
        self.ip_lookup_cache.set(ip_address, domain)

        # Return the domain
        return domain
340112
function lookup(uri, opts) {
    if (typeof uri === "object") {
      opts = uri;
      uri = undefined;
    }

    opts = opts || {};

    var parsed = url_1(uri);
    var source = parsed.source;
    var id = parsed.id;
    var path = parsed.path;
    var sameNamespace = cache[id] && path in cache[id].nsps;
    var newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;

    var io;

    if (newConnection) {
      debug("ignoring socket cache for %s", source);
      io = manager(source, opts);
    } else {
      if (!cache[id]) {
        debug("new io instance for %s", source);
        cache[id] = manager(source, opts);
      }
      io = cache[id];
    }
    if (parsed.query && !opts.query) {
      opts.query = parsed.query;
    }
    return io.socket(parsed.path, opts);
  }
858063
def dns_lookup(host, port, afi=socket.AF_UNSPEC):
    """"""
    # XXX: all DNS functions in Python are blocking. If we really
    # want to be non-blocking here, we need to use a 3rd-party
    # library like python-adns, or move resolution onto its
    # own thread. This will be subject to the default libc
    # name resolution timeout (5s on most Linux boxes)
    try:
        return list(filter(is_inet_4_or_6,
                           socket.getaddrinfo(host, port, afi,
                                              socket.SOCK_STREAM)))
    except socket.gaierror as ex:
        log.warning('DNS lookup failed for %s:%d,'
                    ' exception was %s. Is your'
                    ' advertised.listeners (called'
                    ' advertised.host.name before Kafka 9)'
                    ' correct and resolvable?',
                    host, port, ex)
        return []
1122194
def resolve_real_bind_addr(socket_):
        """"""
        # FIXME: keep requested bind_addr separate real bound_addr (port
        # is different in case of ephemeral port 0)
        bind_addr = socket_.getsockname()
        if socket_.family in (
            # Windows doesn't have socket.AF_UNIX, so not using it in check
            socket.AF_INET,
            socket.AF_INET6,
        ):
            """UNIX domain sockets are strings or bytes.

            In case of bytes with a leading null-byte it's an abstract socket.
            """
            return bind_addr[:2]
        return bind_addr
1137845
def lookup(sock, domain, cache = None):
    """"""
    domain = normalize_domain(domain)

    # cache miss, perform lookup
    reply = sam_cmd(sock, "NAMING LOOKUP NAME=%s" % domain)

    b64_dest = reply.get('VALUE')
    if b64_dest:
        dest = Dest(b64_dest, encoding='base64')
        if cache:
            cache[dest.base32 + '.b32.i2p'] = dest
        return dest
    else:
        raise NSError('Domain name %r not resolved because %r' % (domain, reply))
1138818
function _dns_error (connection, next, err, host, plugin, nxdomain, dnserror) {
    switch (err.code) {
        case dns.NXDOMAIN:
        case dns.NOTFOUND:
        case dns.NOTDATA:
            connection.loginfo(plugin, 'could not find a address for ' + host +
                '. Disconnecting.');
            next(DENYDISCONNECT, 'Sorry we could not find address for ' +
                host + '. ' + nxdomain);
            break;

        default:
            connection.loginfo(plugin, 'encountered an error when looking up ' +
                host + '. Disconnecting.');
            next(DENYDISCONNECT, 'Sorry we encountered an error when ' +
                'looking up ' + host + '. ' + dnserror);
            break;
    }
}
678241
function tryRunAdbReverse(packagerPort: number | string, device: string) {
  try {
    const adbPath = getAdbPath();
    const adbArgs = ['reverse', `tcp:${packagerPort}`, `tcp:${packagerPort}`];

    // If a device is specified then tell adb to use it
    if (device) {
      adbArgs.unshift('-s', device);
    }

    logger.info(`Running ${adbPath} ${adbArgs.join(' ')}`);

    execFileSync(adbPath, adbArgs, {
      stdio: [process.stdin, process.stdout, process.stderr],
    });
  } catch (e) {
    logger.info(`Could not run adb reverse: ${e.message}`);
  }
}
1068434
function lookupAsync(hostname) {
    return new Promise((resolve, reject) => {
        dns.lookup(hostname, { all: true }, (err, addresses) => {
            if (err)
                return reject(err);
            resolve(addresses[0].address);
        });
    });
}
1324741
def attempt_connection(self):
        
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
        self.socket.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2)

        self.receiver_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
        self.receiver_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.receiver_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
        self.receiver_socket.bind(('', MCAST_PORT))
        mreq = struct.pack("4sl", socket.inet_aton(MCAST_GRP), socket.INADDR_ANY)
        self.receiver_socket.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)

        if not self.socket or not self.receiver_socket:
            raise exception.ConnectFailedException()
36559
def cmd_dns_lookup_reverse(ip_address, verbose):
    
    if verbose:
        logging.basicConfig(level=logging.INFO, format='%(message)s')
        print("Looking up %s..." % ip_address, file=sys.stderr)

    answer = lookup_reverse(ip_address)

    if answer:
        print(json.dumps(answer, indent=4))
    else:
        print("[X] %s is not valid IPv4/IPV6 address" % ip_address)

    return True
1191484
function getFqdnForIpAddress(ipAddress, cb) {
  dns.reverse(ipAddress, function(err, fqdns) {
    if (err) {
      cb(err, fqdns);
    } else if (fqdns[0].toLowerCase() === localhostIdentifier) {
      getFqdn(localhostIdentifier, cb);
    } else {
      cb(err, fqdns[0]);
    }
  });
}
386425
def lookup!(nameserver=nil)
      resolver = Resolv.resolver(nameserver)
      hosts = begin
                resolver.getnames(self.address.to_s)
              rescue
                []
              end

      hosts.map! do |name|
        HostName.first_or_create(
          :address => name,
          :ip_addresses => [self]
        )
      end

      return hosts
    end
801814
private void attemptSocketBind(InetSocketAddress address, boolean reuseflag) throws IOException {
        this.serverSocket.setReuseAddress(reuseflag);
        this.serverSocket.bind(address, this.tcpChannel.getConfig().getListenBacklog());
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "ServerSocket bind worked, reuse=" + this.serverSocket.getReuseAddress());
        }
    }
1314889
void resolveHostname(boolean synchronous) {
        Runnable r = new Runnable() {
            @Override
            public void run() {
                String remoteHost = ReverseDNSCache.hostnameOrAddress(m_remoteSocketAddress.getAddress());
                if (!remoteHost.equals(m_remoteSocketAddress.getAddress().getHostAddress())) {
                    m_remoteHostname = remoteHost;
                    m_remoteHostAndAddressAndPort = remoteHost + m_remoteHostAndAddressAndPort;
                    m_toString = VoltPort.this.toString() + ":" + m_remoteHostAndAddressAndPort;
                }
            }
        };
        if (synchronous) {
            r.run();
        } else {
            /*
             * Start the reverse DNS lookup in background because it might be
             * very slow if the hostname is not specified in local /etc/hosts.
             */
            try {
                ReverseDNSCache.submit(r);
            } catch (RejectedExecutionException e) {
                networkLog.debug(
                        "Reverse DNS lookup for " + m_remoteSocketAddress + " rejected because the queue was full");
            }
        }
    }