Rev 60529 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/utils/man/make.socket.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2012 R Core Team% Distributed under GPL 2 or later\name{make.socket}\alias{make.socket}\alias{print.socket}\title{Create a Socket Connection}\usage{make.socket(host = "localhost", port, fail = TRUE, server = FALSE)}\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} the \R processlistens on the specified port for a connection and then returns aserver socket. It is a good idea to use \code{\link{on.exit}} toensure that a socket is closed, as you only get 64 of them.}\value{An object of class \code{"socket"}, a list with components:\item{socket}{socket number. This is for internal use. On aUnix-alike it is a file descriptor.}\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 \dQuote{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)}## Official time (UTC) from US Naval Observatory\dontrun{daytime("tick.usno.navy.mil")}}\keyword{misc}