// PingPong sends a ping and receives a pong, if no pong received then returns false and filled error
969318
func (r *Service) PingPong() (bool, error) {
	c := r.pool.Get()
	defer c.Close()
	msg, err := c.Do("PING")
	if err != nil || msg == nil {
		return false, err
	}
	return (msg == "PONG"), nil
}
1292727
func (p joyentProvider) Ping(ctx context.ProviderCallContext, endpoint string) error {
	return errors.NotImplementedf("Ping")
}
179636
func (s *Server) pingSweep() {
	responses := make(map[string]string, len(s.managedNodes))
	for k := range s.managedNodes {
		_, msg, err := s.managedNodes[k].Ping()
		if err != nil {
			responses[s.managedNodes[k].Address()] = err.Error()
			continue
		}
		responses[s.managedNodes[k].Address()] = msg
	}
}
1106895
func (c *MConnection) stopPongTimer() {
	if c.pongTimer != nil {
		_ = c.pongTimer.Stop()
		c.pongTimer = nil
	}
}
73783
func (c *Client) PingEndpoint() error {
	_, err := c.Restapi.GetHello(nil)
	return err
}
703844
func (rtm *RTM) handlePong(event json.RawMessage) {
	var (
		p Pong
	)

	rtm.resetDeadman()

	if err := json.Unmarshal(event, &p); err != nil {
		rtm.Client.log.Println("RTM Error unmarshalling 'pong' event:", err)
		return
	}

	latency := time.Since(time.Unix(p.Timestamp, 0))
	rtm.IncomingEvents <- RTMEvent{"latency_report", &LatencyReport{Value: latency}}
}
706248
func (d *lbdgpro2whDevice) Ping(rw net.Conn, wait time.Duration) error {
	err := sendString("#PING\r\n", rw)
	if err != nil {
		return err
	}

	reader := bufio.NewReader(rw)
	endTime := time.Now().Add(wait)
	for {
		rw.SetReadDeadline(time.Now().Add(endTime.Sub(time.Now())))
		bytes, _, err := reader.ReadLine()
		rw.SetReadDeadline(time.Time{})
		if err != nil {
			return err
		}

		resp := string(bytes)
		if strings.Contains(resp, "~PING") {
			return nil
		}

		if time.Now().After(endTime) {
			return errors.New("timeout, no ping received")
		}
	}
}
1055213
func (t *UDPv4) ping(n *enode.Node) error {
	return <-t.sendPing(n.ID(), &net.UDPAddr{IP: n.IP(), Port: n.UDP()}, nil)
}
83668
func routes() *pat.Router {
	Router.Get("/ping", func(rw http.ResponseWriter, req *http.Request) {
		rw.Write([]byte("pong\n"))
	})
	// Router.Get("/list", handleRequest(list))
	// Router.Get("/subscribe", handleRequest(subscribe))
	// Router.Get("/unsubscribe", handleRequest(unsubscribe))

	return Router
}
974471
func (p *Pool) pingAndPurgeIfNeeded(other *Pool) error {
	ping := redisPool.Get()
	pong := redis.PubSubConn{redisPool.Get()}
	// Listen for pongs by subscribing to the other pool's pong key
	pong.Subscribe(other.pongKey())
	// Ping the other pool by publishing to its ping key
	ping.Do("PUBLISH", other.pingKey(), 1)
	// Use a select statement to either receive the pong or timeout
	pongChan := make(chan interface{})
	errChan := make(chan error)
	go func() {
		defer func() {
			pong.Close()
			ping.Close()
		}()
		select {
		case <-p.exit:
			return
		default:
		}
		for {
			reply := pong.Receive()
			switch reply.(type) {
			case redis.Message:
				// The pong was received
				pongChan <- reply
				return
			case error:
				// There was some unexpected error
				err := reply.(error)
				errChan <- err
				return
			}
		}
	}()
	timeout := time.After(p.config.StaleTimeout)
	select {
	case <-pongChan:
		// The other pool responded with a pong
		return nil
	case err := <-errChan:
		// Received an error from the pubsub conn
		return err
	case <-timeout:
		// The pool is considered stale and should be purged
		t := newTransaction()
		other.RLock()
		otherId := other.id
		other.RUnlock()
		t.purgeStalePool(otherId)
		if err := t.exec(); err != nil {
			return err
		}
	}
	return nil
}
145298
func (db *nodeDB) lastPong(id NodeID) time.Time {
	return time.Unix(db.fetchInt64(makeKey(id, nodeDBDiscoverPong)), 0)
}
294672
func (c *HyperClient) Ping() (*types.PingResponse, error) {
	resp, err := c.client.Ping(
		c.ctx,
		&types.PingRequest{},
	)

	if err != nil {
		return nil, err
	}

	return resp, nil
}
497539
func (c *rawConnection) pingReceiver() error {
	ticker := time.NewTicker(ReceiveTimeout / 2)
	defer ticker.Stop()

	for {
		select {
		case <-ticker.C:
			d := time.Since(c.cr.Last())
			if d > ReceiveTimeout {
				l.Debugln(c.id, "ping timeout", d)
				return ErrTimeout
			}

			l.Debugln(c.id, "last read within", d)

		case <-c.closed:
			return ErrClosed
		}
	}
}
1065476
func (c *Client) processPingreq() error {
	// send a pingresp packet
	err := c.send(packet.NewPingresp(), true)
	if err != nil {
		return c.die(TransportError, err)
	}

	return nil
}
126599
func (s *ServerRPC) Ping(c context.Context, req *types.PingRequest) (*types.PingResponse, error) {
	return &types.PingResponse{HyperdStats: "OK"}, nil
}
78130
func (p *Pinger) ping() (err error) {
	logger.Tracef("[%s] pinging %q with seq=%d", p.modelUUID[:6], p.beingKey, p.beingSeq)
	defer func() {
		// If the session is killed from underneath us, it panics when we
		// try to copy it, so deal with that here.
		if v := recover(); v != nil {
			err = fmt.Errorf("%v", v)
		}
	}()
	if p.delta == 0 {
		session := p.pings.Database.Session.Copy()
		defer session.Close()
		base := p.base.With(session)
		delta, err := clockDelta(base)
		if err != nil {
			return errors.Trace(err)
		}
		p.delta = delta
	}
	// TODO(perrito666) 2016-05-02 lp:1558657
	slot := timeSlot(time.Now(), p.delta)
	if slot == p.lastSlot {
		// Never, ever, ping the same slot twice.
		// The increment below would corrupt the slot.
		return nil
	}
	p.lastSlot = slot
	p.recorderFunc().Ping(p.modelUUID, slot, p.fieldKey, p.fieldBit)
	return errors.Trace(err)
}
1159136
func (r *PingdomError) Error() string {
	return fmt.Sprintf("%d %v: %v", r.StatusCode, r.StatusDesc, r.Message)
}