Rev 3877 | Blame | Last modification | View Log | Download | RSS feed
\name{make.socket}\title{Create a socket connection}\usage{make.socket(host="localhost", port, fail=TRUE, server=FALSE)close.socket(socket)}\alias{make.socket}\arguments{\item{host}{name of remote host}\item{port}{port to connect to/listen on}\item{fail}{failure to connect is an error?}\item{server}{a server socket?}}\description{With \code{server=FALSE} attempts to open a client socket to thespecified port and host. With \code{server=TRUE} listens on thespecified port for a connection and then returns a server socket. It isa good idea to use \code{\link{on.exit}} to ensure that a socket isclosed, as you only get 64 of them.}\value{An object of class \code{"socket"}.\item{socket}{socket number. This is for internal use}\item{port}{port number of the connection}\item{host}{name of remote computer}}\author{Thomas Lumley}\references{Adapted from Luke Tierney's code for \code{XLISP-Stat}, in turnbased on code from Robbins and Robbins "Practical UNIX Programming"}\section{WARNING}{I don't know if the connecting host name returnedwhen \code{server=TRUE} can be trusted. I suspect not.}\seealso{\code{\link{close.socket}}, \code{\link{read.socket}}}\examples{daytime <- function(host = "localhost"){a <- make.socket(host, 13)on.exit(close.socket(a))read.socket(a)}\dontrun{daytime()} ## only works if your computer runs this service\dontrun{daytime("chime.cac.washington.edu")}}\keyword{misc}