Checks connectivity with the Internet. This operation is performed only once.

@return RxJava Single with Boolean - true, when we have an access to the Internet
and false if not
507234
@RequiresPermission(Manifest.permission.INTERNET)
  public static Single<Boolean> checkInternetConnectivity() {
    InternetObservingSettings settings = InternetObservingSettings.create();
    return checkInternetConnectivity(settings.strategy(), settings.host(), settings.port(),
        settings.timeout(), settings.httpResponse(), settings.errorHandler());
  }
763888
public function connected()
	{
		// Flag to prevent recursion into this function.
		static $checkingConnected = false;

		if ($checkingConnected)
		{
			// Reset this flag and throw an exception.
			$checkingConnected = true;
			die('Recursion trying to check if connected.');
		}

		// Backup the query state.
		$sql      = $this->sql;
		$limit    = $this->limit;
		$offset   = $this->offset;
		$prepared = $this->prepared;

		try
		{
			// Set the checking connection flag.
			$checkingConnected = true;

			// Run a simple query to check the connection.
			$this->setQuery($this->getConnectedQuery());
			$status = (bool) $this->loadResult();
		}
		catch (\Exception $e)
		{
			// If we catch an exception here, we must not be connected.
			$status = false;
		}

		// Restore the query state.
		$this->sql         = $sql;
		$this->limit       = $limit;
		$this->offset      = $offset;
		$this->prepared    = $prepared;
		$checkingConnected = false;

		return $status;
	}
178392
final public boolean isSingleServer() {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "isSingleServer");
        if (!_singleServerSet) {
            JsAdminService service = JsMainAdminComponentImpl.getJsAdminService();
            if (service.isInitialized())
                _isSingleServer = service.isStandaloneServer();
            else
                // If admin service isn't initialised, then assume we are single
                // service.
                _isSingleServer = true;

            _singleServerSet = true;
        }

        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "isSingleServer", new Boolean(_isSingleServer));
        return _isSingleServer;
    }
26204
public function isConnected()
    {
        return $this->synchronized(function ($self) {
            return $self->applicationState->equals(ApplicationStateKeys::get(ApplicationStateKeys::INITIALIZATION_SUCCESSFUL));
        }, $this);
    }
488208
public Observable<Boolean> checkAuthenticatedInBackground() {
    String sessionToken = getSessionToken();
    if (StringUtil.isEmpty(sessionToken)) {
      logger.d("sessionToken is not existed.");
      return Observable.just(false);
    }
    return PaasClient.getStorageClient().checkAuthenticated(sessionToken);
  }
644066
public Single<ByteBuf> getSeqnos() {
    return Single.create(new Single.OnSubscribe<ByteBuf>() {
      @Override
      public void call(final SingleSubscriber<? super ByteBuf> subscriber) {
        if (state() != LifecycleState.CONNECTED) {
          subscriber.onError(new NotConnectedException());
          return;
        }

        ByteBuf buffer = Unpooled.buffer();
        DcpGetPartitionSeqnosRequest.init(buffer);
        DcpGetPartitionSeqnosRequest.vbucketState(buffer, VbucketState.ACTIVE);

        sendRequest(buffer).addListener(new DcpResponseListener() {
          @Override
          public void operationComplete(Future<DcpResponse> future) throws Exception {
            if (future.isSuccess()) {
              ByteBuf buf = future.getNow().buffer();
              try {
                subscriber.onSuccess(MessageUtil.getContent(buf).copy());
              } finally {
                buf.release();
              }
            } else {
              subscriber.onError(future.cause());
            }
          }
        });
      }
    });
  }
305551
public boolean connect() {
        if (client.isConnected()) {
            logger.warn("Already connected");
            return true;
        }
        try {
            logger.info("Connecting to remote host " + remoteHost);
            client.connect(remoteHost);
            client.rlogin(localUser, remoteUser, terminalType);
            writer = new OutputStreamWriter(client.getOutputStream());
            outputReaderThread = new Thread(new OutputReader());
            outputReaderThread.start();
            if (interactive) {
                standardInputReaderThread = new Thread(new StandardInputReader());
                standardInputReaderThread.start();
            }
            try {
                Thread.sleep(200);
            } catch (InterruptedException ex) {
            }
            if (client.isConnected()) {
                return true;
            } else {
                logger.fatal("Client has been immediately disconnected from remote host:" + remoteHost);
                return false;
            }
            //outputReaderThread.
        } catch (IOException e) {
            logger.fatal("Could not connect to remote host:" + remoteHost, e);
            return false;
        }
    }
335664
@Override
    public synchronized boolean checkConnection(final boolean forceReconnect) {
        if (checkConnection(conn)) {
            return true;
        } else if (forceReconnect) {
            try {
                connect();
                recover();

                return true;
            } catch (final Exception ex) {
                logger.debug(dev, "reconnection failure", ex);
                return false;
            }
        }

        return false;
    }
756713
private boolean checkForActiveConnections(int value) {
        /*
         * Check for active connections in the SharedPool
         */
        boolean activeConnections = false;

        /*
         * We have active connections or active pool requests if active requests
         * > 0 or the pool state is not = 1. In either case, we will consider the
         * pool active if statement is true.
         */
        if (value == 0) {
            mcToMCWMapWrite.lock();
            try {
                Collection<MCWrapper> mcWrappers = mcToMCWMap.values();
                Iterator<MCWrapper> mcWrapperIt = mcWrappers.iterator();
                while (mcWrapperIt.hasNext()) {
                    MCWrapper mcw = mcWrapperIt.next();
                    /*
                     * We have atleast one active connection.
                     */
                    /*
                     * If the value is zero, both tests are used.
                     */
                    if (activeRequest.get() > 0) {
                        activeConnections = true;
                        break;
                    } else {
                        int poolState = mcw.getPoolState();
                        if ((poolState != 1) && (poolState != 9)) {
                            activeConnections = true;
                            break;
                        }
                    }
                }
            } finally {
                mcToMCWMapWrite.unlock();
            }
        } else {
            /*
             * Only activeRequest is used.
             */
            if (activeRequest.get() > 0) {
                activeConnections = true;
            }
        }

        return activeConnections;
    }
1231831
public function hasDataToRead()
    {
        if (!$this->isConnected()) {
            throw new ConnectionException('Not connected to any server.', $this->activeHost);
        }

        $isDataInBuffer = $this->connectionHasDataToRead($this->readTimeout[0], $this->readTimeout[1]);
        if (!$isDataInBuffer) {
            $this->observers->emptyBuffer();
        }
        return $isDataInBuffer;
    }
283219
public boolean isOnline()
    {
        Boolean online = getOptionValue(OnlineModeOption.NAME);
        return online == null ? DEFAULT_ONLINE : online;
    }
351363
public boolean isConnectionStale() {
        if (lastUsedTime == 0)
            return false;

        long currentTime = System.currentTimeMillis();
        long timeSinceLastUse = currentTime - lastUsedTime;
        return (timeSinceLastUse > MAX_KEEPALIVE);
    }
1174115
public function isConnected()
    {
        if ($this->connected === false) {
            return false;
        }

        // Check if the socket is still connected
        if ($this->socket->isConnected() === false) {
            $this->connected = false;

            return false;
        }

        return true;
    }
1128840
public boolean isConnected(final Interval<C> that) {
        if(this.hasNone() || that.hasNone()) {
            return false; 
        }
        return this.range.isConnected(that.range);
    }
377195
public static synchronized boolean canConnect(String url) {
        boolean result = false;
        HttpURLConnection conn = null;
        try {
            conn = getNormalCon(formatUrl(url));
            conn.connect();

            int resultCode = conn.getResponseCode();
            result = (200 == resultCode);

                /*
            if (!result) {
                Log.d("canConnect", resultCode + "|" + url);
            }
            // */

        } catch (IOException e) {
            result = false;
//            Log.e("canConnect", url + "|error:" + e.toString());
        } finally {
            if (conn != null) {
                conn.disconnect();
            }
        }

        return result;
    }
758374
def is_connected(self):
        
        if self._client is not None:
            try:
                self._client.server_info()
            except ConnectionFailure:
                return False
            return True
        else:
            return False
178521
public static boolean isConnected(Context context) {
        if (context == null) {
            return true;
        }
        ConnectivityManager cm = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo info = cm.getActiveNetworkInfo();
        return info != null && info.isConnectedOrConnecting();
    }