Decide how to ping
7440
def ping_class
      return Net::Ping::External unless ports
      return Net::Ping::TCP unless @protocol =~ /tcp|udp|http|wmi/
      Net::Ping.const_get(@protocol.upcase)
    end
1187670
def quiet_ping(hostname, timeout=WAIT_TIMEOUT, count=NUM_PACKETS,
               packet_size=PACKET_SIZE, path_finder=False):
    
    myStats = MyStats() # Reset the stats
    mySeqNumber = 0 # Starting value

    try:
        destIP = socket.gethostbyname(hostname)
    except socket.gaierror as e:
        return 0,0,0,0

    myStats.thisIP = destIP

    # This will send packet that we dont care about 0.5 seconds before it starts
    # acrutally pinging. This is needed in big MAN/LAN networks where you sometimes
    # loose the first packet. (while the switches find the way... :/ )
    if path_finder:
        fakeStats = MyStats()
        do_one(fakeStats, destIP, hostname, timeout,
                        mySeqNumber, packet_size, quiet=True)
        time.sleep(0.5)

    for i in range(count):
        delay = do_one(myStats, destIP, hostname, timeout,
                        mySeqNumber, packet_size, quiet=True)

        if delay == None:
            delay = 0

        mySeqNumber += 1

        # Pause for the remainder of the MAX_SLEEP period (if applicable)
        if (MAX_SLEEP > delay):
            time.sleep((MAX_SLEEP - delay)/1000)

    if myStats.pktsSent > 0:
        myStats.fracLoss = (myStats.pktsSent - myStats.pktsRcvd)/myStats.pktsSent
    if myStats.pktsRcvd > 0:
        myStats.avrgTime = myStats.totTime / myStats.pktsRcvd

    # return tuple(max_rtt, min_rtt, avrg_rtt, percent_lost)
    return myStats.maxTime, myStats.minTime, myStats.avrgTime, myStats.fracLoss
186063
def ping(self, *args, **kwargs):
        

        return self._makeApiCall(self.funcinfo["ping"], *args, **kwargs)
470366
def ping(self, status=None):
        
        newping = not self.ping_watchers
        d = defer.Deferred()
        self.ping_watchers.append(d)
        if newping:
            Ping().ping(self.worker.conn).addBoth(self._pong)

        return d
1172728
def _handle_ping(self, packet, protocol):
        
        if 'payload' in packet:
            is_valid_node = True
            node_ids = list(packet['payload'].values())
            for node_id in node_ids:
                if self._repository.get_node(node_id) is None:
                    is_valid_node = False
                    break
            if is_valid_node:
                self._pong(packet, protocol)
        else:
            self._pong(packet, protocol)
625389
function startCheckingArpTable() {
    setInterval(()=>{
        chkArpTable();
        for (const macinfo of Object.values(macs)) {
            pingNet(macinfo.net, macinfo.ip);
        }
    }, CHECK_ARP_TABLE_AND_PING_INTERVAL);
    // Initial check
    chkArpTable();
}
1276864
def receive_ping(self, ping: Ping):
        

        self.log_healthcheck.debug(
            'Ping received',
            message_id=ping.nonce,
            message=ping,
            sender=pex(ping.sender),
        )

        pong = Pong(nonce=ping.nonce)
        self.raiden.sign(pong)

        try:
            self.maybe_send(ping.sender, pong)
        except (InvalidAddress, UnknownAddress) as e:
            self.log.debug("Couldn't send the `Delivered` message", e=e)
606285
function ping(options, callback) {
  const args = utils.getArgs(options, [config], callback);
  const url = `http://${args.options.ip}:${args.options.port}/ping`;

  return request.get(url, function(err) {
    if (err) {
      if (err.code === "ECONNREFUSED") {
        return args.callback(null, { running: false });
      }
      return args.callback(err);
    }
    return args.callback(null, { running: true });
  });
}
733552
def ping():
    '''
    
    '''
    r = salt.utils.http.query(DETAILS['url']+'ping', decode_type='json', decode=True)
    try:
        return r['dict'].get('ret', False)
    except Exception:
        return False
782017
public function ping(){
        $this->command("PING");
        if (strpos($this->getResponse($this->handle), "PONG") === false){
            return false;
        }
        return true;
    }
358842
def ping(self, reconnect=True):
        
        if self._sock is None:
            if reconnect:
                self.connect()
                reconnect = False
            else:
                raise err.Error("Already closed")
        try:
            self._execute_command(COMMAND.COM_PING, "")
            self._read_ok_packet()
        except Exception:
            if reconnect:
                self.connect()
                self.ping(False)
            else:
                raise
1184631
def ping(self):
        
        uri = "%s/%s" % (self.base_uri, "ping")
        resp, data = self.request("GET", uri)
        return data
32210
def ping():
    '''
    
    '''
    try:
        cookie = logon()
        logout(cookie)
    except salt.exceptions.CommandExecutionError:
        return False
    except Exception as err:
        log.debug(err)
        return False
    return True
525523
async def ping(self) -> dict:
        
        if not self._session:
            await self.create_session()
        async with self._session.get(self.url.format(endpoint='ping')) as resp:
            logger.debug(f'{resp.status}: {resp.reason}')
            return dict(resp.headers.items())
313510
function ping (host, callback) {
  var isWin = process.platform.indexOf('win') === 0; // win32 or win64
  var arg = isWin ? '-n' : '-c';
  var pong = spawn('ping', [arg, '3', host]); // only ping 3 times

  pong.on('error', function onerror (error) {
    callback(error, false);
    pong.kill();
  });

  pong.stdout.on('data', function stdoutdata (data) {
    callback(false, data.toString().split('\n')[0].substr(14));
    pong.kill();
  });

  pong.stderr.on('data', function stderrdata (data) {
    callback(new Error(data.toString().split('\n')[0].substr(14)), false);
    pong.kill();
  });
}
125361
def ping(self, params=None):
        
        try:
            return self.transport.perform_request("HEAD", "/", params=params)
        except TransportError:
            return False
272332
function ping() {
        result = fn.apply(context || this, args || []);
        context = args = null;
        executed = true;
      }