The R Project SVN R

Rev

Rev 7002 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7002 Rev 7133
Line 1... Line 1...
1
\name{make.socket}
1
\name{make.socket}
2
\title{Create a socket connection}
2
\title{Create a Socket Connection}
3
\usage{
3
\usage{
4
make.socket(host="localhost", port, fail=TRUE, server=FALSE)
4
make.socket(host = "localhost", port, fail = TRUE, server = FALSE)
5
print.socket(socket)
5
print.socket(socket)
6
}
6
}
7
\alias{make.socket}
7
\alias{make.socket}
8
\alias{print.socket}
8
\alias{print.socket}
9
\arguments{
9
\arguments{
10
    \item{host}{name of remote host}
10
  \item{host}{name of remote host}
11
    \item{port}{port to connect to/listen on}
11
  \item{port}{port to connect to/listen on}
12
    \item{fail}{failure to connect is an error?}
12
  \item{fail}{failure to connect is an error?}
13
    \item{server}{a server socket?}
13
  \item{server}{a server socket?}
14
}
14
}
15
\description{
15
\description{
16
    With \code{server=FALSE} attempts to open a client socket to the
16
  With \code{server = FALSE} attempts to open a client socket to the
17
    specified port and host. With \code{server=TRUE} listens on the
17
  specified port and host. With \code{server = TRUE} listens on the
18
    specified port for a connection and then returns a server socket. It is
18
  specified port for a connection and then returns a server socket. It is
19
    a good idea to use \code{\link{on.exit}} to ensure that a socket is
19
  a good idea to use \code{\link{on.exit}} to ensure that a socket is
20
    closed, as you only get 64 of them.
20
  closed, as you only get 64 of them.
21
}
21
}
22
\value{
22
\value{
23
    An object of class \code{"socket"}.
23
  An object of class \code{"socket"}.
24
    \item{socket}{socket number. This is for internal use}
24
  \item{socket}{socket number. This is for internal use}
25
    \item{port}{port number of the connection}
25
  \item{port}{port number of the connection}
26
    \item{host}{name of remote computer}
26
  \item{host}{name of remote computer}
27
}
27
}
28
\author{Thomas Lumley}
28
\author{Thomas Lumley}
29
\references{
29
\references{
30
    Adapted from Luke Tierney's code for \code{XLISP-Stat}, in turn
30
  Adapted from Luke Tierney's code for \code{XLISP-Stat}, in turn
31
    based on code from Robbins and Robbins "Practical UNIX Programming"
31
  based on code from Robbins and Robbins "Practical UNIX Programming"
32
}
32
}
33
\section{WARNING}{
33
\section{WARNING}{
34
    I don't know if the connecting host name returned
34
  I don't know if the connecting host name returned
35
    when \code{server=TRUE} can be trusted. I suspect not.
35
  when \code{server = TRUE} can be trusted. I suspect not.
36
} 
36
} 
37
 
37
 
38
\seealso{
38
\seealso{
39
    \code{\link{close.socket}}, \code{\link{read.socket}}
39
  \code{\link{close.socket}}, \code{\link{read.socket}}
40
}
40
}
41
 
41
 
42
\examples{
42
\examples{
43
daytime <- function(host = "localhost"){
43
daytime <- function(host = "localhost"){
44
    a <- make.socket(host, 13)
44
    a <- make.socket(host, 13)