If connected to server.
186808
def connected(self):
        
        return self.websocket is not None and \
               self.websocket.sock is not None and \
               self.websocket.sock.connected
349556
protected synchronized boolean checkConnection()
    {
        if (_connection==null)
        {
            try{
                _connection=_url.openConnection();
            }
            catch(IOException e)
            {
                LogSupport.ignore(log,e);
            }
        }
        return _connection!=null;
    }
473672
def after_start_check(self):
        """"""
        try:
            conn = HTTPConnection(self.host, self.port)

            conn.request('HEAD', self.url.path)
            status = str(conn.getresponse().status)

            if status == self.status or self.status_re.match(status):
                conn.close()
                return True

        except (HTTPException, socket.timeout, socket.error):
            return False
341579
public function connected()
    {
        if (is_resource($this->smtp_conn)) {
            $sock_status = stream_get_meta_data($this->smtp_conn);
            if ($sock_status['eof']) {
                // the socket is valid but we are not connected
                if ($this->do_debug >= 1) {
                    $this->edebug(
                        'SMTP NOTICE: EOF caught while checking if connected'
                    );
                }
                $this->close();
                return false;
            }
            return true; // everything looks good
        }
        return false;
    }
434826
async def on_open(self):
        """"""

        self.__ensure_barrier()
        while self.connected:
            try:
                if self.__lastping > self.__lastpong:
                    raise IOError("Last ping remained unanswered")

                self.send_message("2")
                self.send_ack()
                self.__lastping = time.time()
                await asyncio.sleep(self.ping_interval)
            except Exception as ex:
                LOGGER.exception("Failed to ping")
                try:
                    self.reraise(ex)
                except Exception:
                    LOGGER.exception(
                        "failed to force close connection after ping error"
                    )
                break
251102
@Override
    void networkReachable() {
        synchronized (lock) {
            if (c4repl == null) {
                Log.i(DOMAIN, "%s: Server may now be reachable; retrying...", this);
                retryCount = 0;
                retry();
            }
        }
    }
270881
def alive(opts):
    '''
    
    '''

    dev = conn()

    thisproxy['conn'].connected = ping()

    if not dev.connected:
        __salt__['event.fire_master']({}, 'junos/proxy/{}/stop'.format(
            opts['proxy']['host']))
    return dev.connected
71630
def status(self):
        """"""
        try:
            # -- Check client
            res = self.run(['info'])
            if res[0]['clientName'] == '*unknown*':
                return ConnectionStatus.INVALID_CLIENT
            # -- Trigger an auth error if not logged in
            self.run(['user', '-o'])
        except errors.CommandError as err:
            if 'password (P4PASSWD) invalid or unset' in str(err.args[0]):
                return ConnectionStatus.NO_AUTH
            if 'Connect to server failed' in str(err.args[0]):
                return ConnectionStatus.OFFLINE

        return ConnectionStatus.OK
592937
def is_running(self, port):
        """"""
        try:
            con = self.client('localhost:%s' % port)
            con.admin.command('ping')
            return True
        except (AutoReconnect, ConnectionFailure, OperationFailure):
            # Catch OperationFailure to work around SERVER-31916.
            return False
846488
def _on_open(self, _):
        """"""
        nick = self._format_nick(self._nick, self._pwd)
        data = {"cmd": "join", "channel": self._channel, "nick": nick}
        self._send_packet(data)
        self._thread = True
        threading.Thread(target=self._ping).start()
946201
function Ready()
	{
		if (options.autoconnect)
		{
			// make a connection request immediately (optional)
			parent.GetPSN(true, function() {
				if (options.onReady) options.onReady();
				return;
			});
		}
		else
		{
			// just callback that we're ready (if anyone is listening)
			if (options.onReady) options.onReady();
			return;
		}
	}
1320995
private void connected(final MemcachedNode node) {
    assert node.getChannel().isConnected() : "Not connected.";
    int rt = node.getReconnectCount();
    node.connected();

    for (ConnectionObserver observer : connObservers) {
      observer.connectionEstablished(node.getSocketAddress(), rt);
    }
  }
163834
function checkStatus() {
  return server.ping(this, function(err, res) {
    if (err) {
      return out.error("error occurred: %j", err);
    }
    if (res.running) {
      return out.success("service running");
    }
    return out.error("service not running");
  });
}
791406
def monitor(self, name, ip, port, quorum):
        """"""
        fut = self.execute(b'MONITOR', name, ip, port, quorum)
        return wait_ok(fut)
499919
function onConnect(err) {
    if (err) {
      DEBUG("connect error", err)
      return cb(err)
    }

    DEBUG("connected")

    channel.sendMessage({
      type: "request",
      name: "connect",
      to:   "server",
      id:   "0",
      body: {
        key: config.key
      }
    })
  }
287339
function (e,data) {
			if (!_.isObject(e) || _.isUndefined(data))
				return false;
				
			if (server.getConfig('consoleID') == this.activeServer)
				return true;
			return false;
		}
73361
public void run() {

		try {
			while (true) {
				//server thread blocks until a client connects
				Socket socket = server.accept();

				System.out.println(new LogEntry("client (" + socket.getInetAddress().getHostAddress() + ") attempts to connect..."));
				Connection c = establishConnection(socket);
				updateConnectedClients(c);
			}
		} catch (IOException ioe) {
			System.out.println(new LogEntry("server forced to stop with message " + ioe.getClass().getName() + ' ' + ioe.getMessage()));
		} catch (Throwable t) {
			System.out.println(new LogEntry(Level.CRITICAL, "server forced to stop with message " + t.getClass().getName() + ' ' + t.getMessage(), t));
		}
	}