Sends a ping packet to ID's from 0 to maximum and prints out any returned
	messages.

	Actually send a broadcast and will retry (resend) the ping 3 times ...
331954
def sweep(port, rate, ID, retry=3):
	
	if port == 'dummy':
		s = ServoSerial(port, rate, fake=True)
	else:
		s = ServoSerial(port, rate)

	if ID < 0:
		ID = xl320.XL320_BROADCAST_ADDR

	try:
		s.open()
	except SerialException as e:
		# print('Error opening serial port:')
		print('-'*40)
		print(sys.argv[0], ':')
		print(e)
		exit(1)

	pkt = makePingPacket(ID)
	# print('ping', pkt)
	s.write(pkt)

	# as more servos add up, I might need to increase the cnt number???
	for cnt in range(retry):
		ans = s.read()

		if ans:
			for pkt in ans:
				servo = packetToDict(pkt)
				utils.prettyPrintPacket(servo)
				print('raw pkt: {}'.format(pkt))
		else:
			print('Try {}: no servos found'.format(cnt))

		time.sleep(0.1)

	s.close()
70988
public void pingReceived(Ping pong) {
        long now = System.currentTimeMillis();
        long previousPingTime = lastPingSentOn.get();
        int previousPingValue = (int) (previousPingTime & 0xffffffffL);
        int pongValue = pong.getValue2().intValue();
        if (log.isDebugEnabled()) {
            log.debug("Pong received: session=[{}] at {} with value {}, previous received at {}", new Object[] { getSessionId(), now, pongValue, previousPingValue });
        }
        if (pongValue == previousPingValue) {
            lastPingRoundTripTime.set((int) ((now - previousPingTime) & 0xffffffffL));
            if (log.isDebugEnabled()) {
                log.debug("Ping response session=[{}], RTT=[{} ms]", new Object[] { getSessionId(), lastPingRoundTripTime.get() });
            }
        } else {
            // don't log the congestion entry unless there are more than X messages waiting
            if (getPendingMessages() > 4) {
                int pingRtt = (int) ((now & 0xffffffffL)) - pongValue;
                log.info("Pong delayed: session=[{}], ping response took [{} ms] to arrive. Connection may be congested, or loopback", new Object[] { getSessionId(), pingRtt });
            }
        }
        lastPongReceivedOn.set(now);
    }
525874
def ping(self):
        """"""

        ret, data = self.sendmess(MSG_NOP, bytes())
        if data or ret > 0:
            raise ProtocolError('invalid reply to ping message')
        if ret < 0:
            raise OwnetError(-ret, self.errmess[-ret])
198847
def send(self, payloads, logger, num_tries=5):
        
        from time import sleep

        backoff_interval = 1
        backoff_factor = 2

        for try_counter in xrange(0, num_tries):
            failed_messages = self.send_without_retry(payloads)

            # success!
            if not failed_messages:
                payloads = []
                break

            # output some information about the failures for debugging
            # purposes. we expect failures to be quite rare, so we can be
            # pretty verbose.
            if logger:
                for msg in failed_messages:
                    logger.warning("Failed to send message on try %d: Id=%r, "
                                   "SenderFault=%r, Code=%r, Message=%r" %
                                   (try_counter, msg['Id'],
                                    msg.get('SenderFault'), msg.get('Code'),
                                    msg.get('Message')))

            # wait a little while, in case the problem is that we're talking
            # too fast.
            sleep(backoff_interval)
            backoff_interval *= backoff_factor

            # filter out the failed payloads for retry
            retry_payloads = []
            for msg in failed_messages:
                i = int(msg['Id'])
                retry_payloads.append(payloads[i])
            payloads = retry_payloads

        if payloads:
            raise Exception('Messages failed to send to sqs after %d '
                            'retries: %s' % (num_tries, len(payloads)))
477612
async def ping(self, reconnect=True):
        """"""
        if self._writer is None and self._reader is None:
            if reconnect:
                await self._connect()
                reconnect = False
            else:
                raise Error("Already closed")
        try:
            await self._execute_command(COMMAND.COM_PING, "")
            await self._read_ok_packet()
        except Exception:
            if reconnect:
                await self._connect()
                await self.ping(False)
            else:
                raise
1146260
def ping(self):
        
        msg_code = riak.pb.messages.MSG_CODE_PING_REQ
        codec = self._get_codec(msg_code)
        msg = codec.encode_ping()
        resp_code, _ = self._request(msg, codec)
        if resp_code == riak.pb.messages.MSG_CODE_PING_RESP:
            return True
        else:
            return False
1238033
def _no_answer_do_retry(self, pk, pattern):
        """"""
        logger.info('Resending for pattern %s', pattern)
        # Set the timer to None before trying to send again
        self.send_packet(pk, expected_reply=pattern, resend=True)
1301232
def send(self, out, addr=_MDNS_ADDR, port=_MDNS_PORT):
        """"""
        # This is a quick test to see if we can parse the packets we generate
        #temp = DNSIncoming(out.packet())
        for i in self.intf.values():
            try:
                return i.sendto(out.packet(), 0, (addr, port))
            except:
                traceback.print_exc()
                # Ignore this, it may be a temporary loss of network connection
                return -1
474638
def broadcast(self, clients, msg):
        
        json_msg = None

        count = 0

        for c in clients:
            sess = c.session
            if not sess.is_closed:
                if sess.send_expects_json:
                    if json_msg is None:
                        json_msg = proto.json_encode(msg)
                    sess.send_jsonified(json_msg, stats=False)
                else:
                    sess.send_message(msg, stats=False)

                count += 1

        self.stats.packSent(count)
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)
728524
function transmit(sensor)
{
    var buffer = "Ping " + count;
    count++;
    console.log("Sending... " + buffer);

    sensor.sendStr(buffer, 3000);
    sensor.setSleep();
}
1328948
public void ping(long id, long timeout, PingCallback callback) {
        pingCallbacks.put(id, callback);
        scheduller.postMessage(new MTPing(id), false, timeout);
        actionsActor.send(new PingTimeout(id), timeout);
    }
1324239
def ping(self):
        
        d = self.replyQueue.get_ping()
        packet = RequestPing(self.charset, self.errors)
        self.transport.write(bytes(packet))
        return d.addCallback(self.handle_reply, self.charset, self.errors, None)
971733
def send_msg(self, connection, data):
        
        # serialize as JSON
        msg = json.dumps(data)
        # Prefix each message with a 4-byte length (network byte order)
        msg = struct.pack('>I', len(msg)).decode() + msg
        connection.sendall(msg.encode())
        return
888003
def send(self, packet, retry=True):
        """"""
        addr = ('255.255.255.255', self.port)  # 255. is the broadcast IP for UDP
        try:
            self.send_socket.sendto(packet, addr)
        except Exception as e:
            self.log("Link failed to send packet over socket %s" % e)
            sleep(0.2)
            if retry:
                self.send(packet, retry=False)
1274464
def _process_ping(self):
        
        yield self.send_command(PONG_PROTO)
        if self._flush_queue.empty():
            yield self._flush_pending()
528668
def ping(self, ips, boardcast=False,
             count=2, timeout=2, interface=None):
        
        cmd = ['ping', '-c', str(count), '-W', str(timeout)]
        True if not interface else cmd.extend(['-I', interface])
        True if not boardcast else cmd.append('-b')
        # Batch create subprocess
        data = dict()
        try:
            for ip in ips:
                stdcode, stdout = agent_utils.execute(cmd + [ip])
                if stdcode:
                    data[ip] = 100
                else:
                    pattern = r',\s([0-9]+)%\spacket\sloss'
                    data[ip] = re.search(pattern, stdout[-2]).groups()[0]
            return agent_utils.make_response(code=0, data=data)
        except Exception as e:
            message = e.message
            return agent_utils.make_response(code=1, message=message)