Returns true if the server can open a connection.
6543
@Override
  public boolean canOpenWarm()
  {
    State state = _state;

    if (state == State.ACTIVE) {
      return true;
    }
    else if (state.isEnabled()) {
      long now = CurrentTime.currentTime();

      if (isFailed(now)) {
        return false;
      }

      long firstSuccessTime = _firstSuccessTime;
      int warmupState = 0;

      if (firstSuccessTime > 0) {
        warmupState = (int) ((now - firstSuccessTime) / _warmupChunkTime);
      }

      warmupState -= _currentFailCount;

      if (warmupState < 0) {
        return (_failTime - warmupState * _failChunkTime < now);
      }
      else if (WARMUP_MAX <= warmupState) {
        return true;
      }

      int connectionMax = WARMUP_CONNECTION_MAX[warmupState];

      int idleCount = getIdleCount();
      int activeCount = _activeCount.get() + _startingCount.get();
      int totalCount = activeCount + idleCount;
      
      return totalCount < connectionMax;
    }
    else {
      return false;
    }
  }
370516
public boolean connectIfNeeded() {
        if (getDDP().getState() == CONNSTATE.Disconnected) {
            // make connection to Meteor server
            getDDP().connect();
            return true;
        } else if (getDDP().getState() == CONNSTATE.Closed) {
           // try to reconnect w/ a new connection
            createDDPClient();
            getDDP().connect();
        }
        return false;
    }
1204065
def is_connectable(port, host="localhost"):
    
    socket_ = None
    try:
        socket_ = socket.create_connection((host, port), 1)
        result = True
    except _is_connectable_exceptions:
        result = False
    finally:
        if socket_:
            socket_.close()
    return result
321019
public static boolean available(final String host, final int port)
	{
		Socket socket = null;
		try
		{
			socket = newSocket(host, port);
			return false;
		}
		catch (final IOException ignored)
		{
			return true;
		}
		finally
		{
			if (!closeClientSocket(socket))
			{
				LOGGER.error("Socket could not be closed on host " + host + " on port " + port);
			}
		}
	}
18953
def is_available(self):
        
        if self.scheme in NOOP_PROTOCOLS:
            return True

        if not self.port:
            raise RuntimeError('port is required')

        s = socket.socket()
        try:
            s.connect((self.host, self.port))
        except Exception:
            return False
        else:
            return True
735327
def open(self):
        """"""
        self._id = str(uuid.uuid4())
        self._client.open_connection(self._id, info=self._connection_args)
283624
public boolean canPing() {
        try {
            val connection = (HttpURLConnection) new URL(this.swivelUrl).openConnection();
            connection.setRequestMethod(HttpMethod.GET.name());
            connection.connect();
            return connection.getResponseCode() == HttpStatus.SC_OK;
        } catch (final Exception e) {
            LOGGER.warn(e.getMessage(), e);
        }
        return false;
    }
1233816
public function isSslConnection()
	{
		$serverSSLVar = $this->input->server->getString('HTTPS', '');

		if (!empty($serverSSLVar) && strtolower($serverSSLVar) !== 'off')
		{
			return true;
		}

		$serverForwarderProtoVar = $this->input->server->getString('HTTP_X_FORWARDED_PROTO', '');

		return !empty($serverForwarderProtoVar) && strtolower($serverForwarderProtoVar) === 'https';
	}
1173896
boolean containsInstallOrOpen() {
        synchronized (reqQueueLockObject) {
            for (ServerRequest req : queue) {
                if (req != null &&
                        ((req instanceof ServerRequestRegisterInstall) || req instanceof ServerRequestRegisterOpen)) {
                    return true;
                }
            }
        }
        return false;
    }
1193351
def allow_inbound_connection(self):
        
        LOGGER.debug("Determining whether inbound connection should "
                     "be allowed. num connections: %s max %s",
                     len(self._connections),
                     self._max_incoming_connections)
        return self._max_incoming_connections >= len(self._connections)
762309
public boolean isSupportedByServer()
            throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
        return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(NAMESPACE);
    }
1238826
def check_port(port, host, timeout=10):
    
    logger.info("trying to open connection to %s:%s", host, port)
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    try:
        sock.settimeout(timeout)
        result = sock.connect_ex((host, port))
        logger.info("was connection successful? errno: %s", result)
        if result == 0:
            logger.debug('port is opened: %s:%s' % (host, port))
            return True
        else:
            logger.debug('port is closed: %s:%s' % (host, port))
            return False
    finally:
        sock.close()
18335
public final boolean isDatastoreConnectionOpen() {
        if (_datastoreConnectionRef == null) {
            return false;
        }
        final UsageAwareDatastoreConnection<E> dataContextProvider = _datastoreConnectionRef.get();
        return isDataContextProviderOpen(dataContextProvider);
    }
1325953
def can_read(self, timeout=0):
        ""
        sock = self._sock
        if not sock:
            self.connect()
            sock = self._sock
        return self._parser.can_read() or \
            bool(select([sock], [], [], timeout)[0])
1025568
def can_read(self, timeout=0):
        ""
        sock = self._sock
        if not sock:
            self.connect()
            sock = self._sock
        return self._parser.can_read() or self._selector.can_read(timeout)
651125
public function isServerAvailable($server)
    {
        $result = $this->tcp->connect($server, $this->config->getPort(), $this->config->getConnectTimeout());
        if ($result) {
            $this->tcp->close();
        }

        return $result;
    }
881317
async def _connect(self):
        """"""
        self.waiting = True
        await self.client.start(self.ip)
        self.waiting = False
        if self.client.protocol is None:
            raise IOError("Could not connect to '{}'.".format(self.ip))
        self.open = True