With server = FALSE attempts to open a client socket to the
specified port and host. With server = TRUE the Rprocess
listens on the specified port for a connection and then returns a
server socket. It is a good idea to use on.exit to
ensure that a socket is closed, as you only get 64 of them.
Usage
make.socket(host = "localhost", port, fail = TRUE, server = FALSE)
Arguments
host
name of remote host
port
port to connect to/listen on
fail
failure to connect is an error?
server
a server socket?
Value
An object of class "socket", a list with components:
socketsocket number. This is for internal use. On a
Unix-alike it is a file descriptor.
portport number of the connection.
hostname of remote computer.
Warning
I don't know if the connecting host name returned
when server = TRUE can be trusted. I suspect not.
References
Adapted from Luke Tierney's code for XLISP-Stat, in turn
based on code from Robbins and Robbins Practical UNIX Programming.
daytime <- function(host = "localhost"){
a <- make.socket(host, 13)
on.exit(close.socket(a))
read.socket(a)
}
## Official time (UTC) from US Naval Observatorydaytime("tick.usno.navy.mil")