Check web connection.
    Returns True if web connection is OK, False otherwise.
166800
def connection_ok():
    
    try:
        urlopen(Dataset.base_url, timeout=1)
        # if an index page is ever added, this will pass through
        return True
    except HTTPError:
        # There's no index for BASE_URL so Error 404 is expected
        return True
    except URLError:
        # This is raised if there is no internet connection
        return False
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());
  }
148819
def _is_valid_url(self, url):
        """"""
        try:
            r = requests.head(url, proxies=self.proxy_servers)
            value = r.status_code in [200]
        except Exception as error:
            logger.error(str(error))
            value = False

        return value
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
329346
def check_status(self):
        
        try:
            r = requests.get(self.host + '/status', auth=self.auth,
                             timeout=(10.0, 10.0))
            if not r.status_code == requests.codes.ok:
                print("Problem connecting to server at %s" % self.host)
                print("status code: %s" % r.status_code)
                return False
            else:
                print("Connected to server at %s" % self.host)
                return True
        except (requests.exceptions.ConnectionError,
                requests.exceptions.MissingSchema,
                requests.exceptions.InvalidSchema) as e:
            print("Problem connecting to server at %s" % self.host)
            print("error: %s" % e)
            return False
1291920
def _check_if_url_valid(url):
        
        r = requests.head(url)
        if r.status_code == 200:
            return True
        else:
            return False
305693
def wait_for_connection(self, timeout=10):
        
        start_time = datetime.datetime.now()
        while True:
            if self.connected:
                return True
            now = datetime.datetime.now()
            if (now - start_time).total_seconds() > timeout:
                return False
            time.sleep(0.5)
1229652
public boolean isAlive(Connection conn)
    {
        try
        {
            return con != null ? !con.isClosed() : false;
        }
        catch (SQLException e)
        {
            log.error("IsAlive check failed, running connection was invalid!!", e);
            return false;
        }
    }
1064426
def is_broken_link(url):
    """"""
    try:
        request = urllib_request.Request(
            url, headers={'User-Agent': 'Mozilla/5.0'})
        urllib_request.urlopen(request).read()
        return False
    except urllib_request.URLError:
        return True
    except SocketError:
        return True
939220
def check_for_connection(self):
        
        for idx, arg in enumerate(self.args):
            if arg.startswith('@'):
                if arg[1:] not in config.connections:
                    self.parser.error("Undefined connection '{}'!".format(arg[1:]))
                config.scgi_url = config.connections[arg[1:]]
                self.LOG.debug("Switched to connection %s (%s)", arg[1:], config.scgi_url)
                del self.args[idx]
                break
437200
function checkConnection(options, cb) {
    if (count < options.attempts) {
        connectServer(options, callback);
    } else {
        var avg = results.reduce(function(prev, curr) { return prev + curr.time; }, 0);
        var max = results.reduce(function(prev, curr) { return (prev > curr.time) ? prev : curr.time; }, results[0].time);
        var min = results.reduce(function(prev, curr) { return (prev < curr.time) ? prev : curr.time; }, results[0].time);

        avg = avg / results.length;
        var out = {
            address:  options.address,
            port:     options.port,
            attempts: options.attempts,
            avg:      avg,
            max:      max,
            min:      min,
            results:  results
        };

        cb(undefined, out);
    }
}
1120818
def _validate_conn(self, conn):
        
        super(HTTPSConnectionPool, self)._validate_conn(conn)

        # Force connect early to allow us to validate the connection.
        if not getattr(conn, 'sock', None):  # AppEngine might not have  `.sock`
            conn.connect()

        if not conn.is_verified:
            warnings.warn((
                'Unverified HTTPS request is being made. '
                'Adding certificate verification is strongly advised. See: '
                'https://urllib3.readthedocs.org/en/latest/security.html'),
                InsecureRequestWarning)
284860
def check_internet_connection(self, remote_server: str = "api.isogeo.com") -> bool:
        
        try:
            # see if we can resolve the host name -- tells us if there is
            # a DNS listening
            host = socket.gethostbyname(remote_server)
            # connect to the host -- tells us if it's reachable
            sock = socket.create_connection((host, 80), 2)
            sock.close()
            return True
        except Exception as e:
            logging.error(e)
            return False
132768
def _check_connections(self):
        """"""

        for server in self._servers:
            if self._is_reachable(server):
                server['down_until'] = 0
            else:
                server['down_until'] = time.time() + 5
1033169
private boolean ping() {
        try {
            URL alfrescoTomcatUrl = buildFinalUrl("");
            TelnetClient telnetClient = new TelnetClient();
            telnetClient.setDefaultTimeout(500);
            telnetClient.connect(alfrescoTomcatUrl.getHost(), alfrescoTomcatUrl.getPort());
            return true;
        } catch (Exception ex) {
            return false;
        }
    }
290701
def _connection_failed(self, link_uri, msg):
        """"""
        print('Connection to %s failed: %s' % (link_uri, msg))
        self.is_connected = False
124835
def check_status(self):
        
        log = logging.getLogger("%s.%s" % (self.log_name,
                                           inspect.stack()[0][3]))
        log.setLevel(self.log_level)

        if self.url:
            return True
        try:
            result = requests.get(self.ext_url)
            self.url = self.ext_url
            return True
        except requests.exceptions.ConnectionError:
            pass
        try:
            result = requests.get(self.local_url)
            log.warning("Url '%s' not connecting. Using local_url '%s'" % \
                     (self.ext_url, self.local_url))
            self.url = self.local_url
            return True
        except requests.exceptions.ConnectionError:
            self.url = None
            log.warning("Unable to connect using urls: %s" % set([self.ext_url,
                                                               self.local_url]))
            return False