0

I am trying to implement an "update checker" R code snippet where the updates are provided via a network computer.

How can I find out via R code if the computer has an active network connection?

Non-functional requirements:

  • must work fast (no long timeout)
  • low package dependencies
  • should be OS independent (no use system shell commands)
  • the solution should (= nice to have) not depend on firewall settings (which may "fake" eg. ping responses)
  • the solution should not use public internet addresses like google for privacy reasons

Is there a package or a code snippet for that? Any hint is welcome :-)

PS: Currently my best approach is using

pingr::is_up("ip.or.URI", fail_on_dns_error = T, timeout = 0.25)

but if I am completely offline (WLAN disabled) the timeout is still not respected on my Windows computer and takes about 10 seconds.

PS 2: Other "tricks" like download.file do even take longer to time out (30 s)...

R Yoda
  • 7,668
  • 2
  • 47
  • 76
  • See also similar (non-R) questions like https://stackoverflow.com/questions/100841/artificially-create-a-connection-timeout-error and https://stackoverflow.com/questions/3764291/checking-network-connection – R Yoda Jul 08 '21 at 17:26

0 Answers0