R/networking.R

Defines functions using_host online

Documented in online using_host

#' @rdname networking
#' @title Checks related to networking
#'
#' @description `online()` uses [curl::has_internet] to check whether the
#' machine is connected to the internet
#'
#' @return A logical value
#' @export
#'
#' @examples
#' online()
online <- function() {
  curl::has_internet()
}

#' @rdname networking
#' @param hostname String containing a hostname or hostnames to check
#' @export
#' @examples
#' using_host("somehost.fakedomain.com")
using_host <- function(hostname) {
  unname(Sys.info()["nodename"] == hostname)
}

Try the ami package in your browser

Any scripts or data that you put into this service are public.

ami documentation built on April 4, 2025, 2:39 a.m.