Check Whether a Localhost Server Can Be Used
Source:R/has_localhost_server.R
has_localhost_server.RdTemporarily opens a server socket and connects to it through localhost.
Both sockets are closed after the check. No existing server is required.