Send a ping message with a given timeout
196152
def ping(timeout=nil)
      request = Message::Ping.new(Thread.mailbox)
      send_request request, :request, timeout
    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
883013
async def __handle_ping(self, _ : Ping):
        
        self.__last_ping = time.time()
        await ZMQUtils.send(self.__backend_socket, Pong())
12653
def send(self, msg, timeout=None, callback=None, raw=False):
        '''
        
        '''
        message_id = self._message_id()
        header = {'mid': message_id}

        future = tornado.concurrent.Future()
        if callback is not None:
            def handle_future(future):
                response = future.result()
                self.io_loop.add_callback(callback, response)
            future.add_done_callback(handle_future)
        # Add this future to the mapping
        self.send_future_map[message_id] = future

        if self.opts.get('detect_mode') is True:
            timeout = 1

        if timeout is not None:
            send_timeout = self.io_loop.call_later(timeout, self.timeout_message, message_id)
            self.send_timeout_map[message_id] = send_timeout

        # if we don't have a send queue, we need to spawn the callback to do the sending
        if not self.send_queue:
            self.io_loop.spawn_callback(self._stream_send)
        self.send_queue.append((message_id, salt.transport.frame.frame_msg(msg, header=header)))
        return future
657237
def write_ping(self, data: bytes) -> None:
        """"""
        assert isinstance(data, bytes)
        self._write_frame(True, 0x9, data)
1095838
def sendcmd(self, cmd='AT', timeout=1.0):
        """"""
        import time
        if self.write(cmd):
            while self.get_response() == '' and timeout > 0:
                time.sleep(0.1)
                timeout -= 0.1
        return self.get_lines()
297485
def sendline(command):
    '''
    
    '''
    if ping() is False:
        init()
    out, _ = DETAILS[_worker_name()].sendline(command)
    return out
292679
def send_ping(self, payload=None):
        
        yield from asyncio.sleep(self._interval)
        self._handler.send_ping(payload=payload)
        self._start_timer(payload=payload)
308273
def timer(message):
    ""
    tick = time.time()
    yield
    tock = time.time()
    print("%s: %.3f seconds" % (message, (tock - tick)))
150669
def ping():
    '''
    
    '''
    try:
        client = _get_client()
        client.info()
    except SaltSystemExit as err:
        log.warning(err)
        return False

    return True
285232
def _send(self, messagetype, packet):
		""""""

		packet.validate()
		data = packet.encode()

		logger.debug('To : %s:%s <%s>\n%s', self.hostname, self.port, packet.__class__, data)

		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		s.settimeout(self.socketTimeout)
		try:
			s.connect((self.hostname, self.port))
			s.send(data)
			recv_data = s.recv(1024)
			while not recv_data.endswith(gntp.shim.b("\r\n\r\n")):
				recv_data += s.recv(1024)
		except socket.error:
			# Python2.5 and Python3 compatibile exception
			exc = sys.exc_info()[1]
			raise errors.NetworkError(exc)

		response = gntp.core.parse_gntp(recv_data)
		s.close()

		logger.debug('From : %s:%s <%s>\n%s', self.hostname, self.port, response.__class__, response)

		if type(response) == gntp.core.GNTPOK:
			return True
		logger.error('Invalid response: %s', response.error())
		return response.error()
1172048
def _hm_send_msg(self, message):
        """"""
        try:
            serial_message = message
            self.conn.write(serial_message)   # Write a string
        except serial.SerialTimeoutException:
            serror = "Write timeout error: \n"
            sys.stderr.write(serror)
        # Now wait for reply
        byteread = self.conn.read(159)
        # NB max return is 75 in 5/2 mode or 159 in 7day mode
        datal = list(byteread)
        return datal
580243
protected void ping(ManagerConnection c)
    {
        try
        {
            if (timeout <= 0)
            {
                c.sendAction(new PingAction(), null);
            }
            else
            {
                final ManagerResponse response;

                response = c.sendAction(new PingAction(), timeout);
                logger.debug("Ping response '" + response + "' for " + c.toString());
            }
        }
        catch (Exception e)
        {
            logger.warn("Exception on sending Ping to " + c.toString(), e);
        }
    }
1272218
def ping(**kwargs):
    '''
    
    '''
    status = True
    try:
        nodes(**kwargs)
    except CommandExecutionError:
        status = False

    return status
574186
def handle_ping(self, message_header, message):
        
        log.debug("handle ping")
        pong = Pong()
        pong.nonce = message.nonce
        log.debug("send pong")
        self.send_message(pong)
176407
def ping(self, callback=None, **kwargs):
        
        self.client.fetch(
            self.mk_req('', method='HEAD', **kwargs),
            callback = callback
        )
35842
private ErrorCode sendPing() throws IOException {
        if(LOGGER.isTraceEnabled()){
            LOGGER.trace("......................send Ping");
        }
        lastPingSentNs = System.currentTimeMillis();
        ProtocolHeader h = new ProtocolHeader(-2, ProtocolType.Ping);
        sendAdminPacket(h, null);

        int waitTime = session.pingWaitTimeOut;

        synchronized(pingResponse){
            while(waitTime > 0){
                try {
                    pingResponse.wait(waitTime);
                } catch (InterruptedException e) {
                    // Do nothing.
                }

                ResponseHeader header = pingResponse.get();
                if (header != null) {
                    pingResponse.set(null);
                    return header.getErr();
                }
                waitTime -= (System.currentTimeMillis() - lastPingSentNs);
            }
        }
        return ErrorCode.PING_TIMEOUT;
    }