EVOLUTION-MANAGER
Edit File: read.socket.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Read from or Write to a Socket</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for read.socket {utils}"><tr><td>read.socket {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Read from or Write to a Socket</h2> <h3>Description</h3> <p><code>read.socket</code> reads a string from the specified socket, <code>write.socket</code> writes to the specified socket. There is very little error checking done by either. </p> <h3>Usage</h3> <pre> read.socket(socket, maxlen = 256L, loop = FALSE) write.socket(socket, string) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>socket</code></td> <td> <p>a socket object.</p> </td></tr> <tr valign="top"><td><code>maxlen</code></td> <td> <p>maximum length (in bytes) of string to read.</p> </td></tr> <tr valign="top"><td><code>loop</code></td> <td> <p>wait for ever if there is nothing to read?</p> </td></tr> <tr valign="top"><td><code>string</code></td> <td> <p>string to write to socket.</p> </td></tr> </table> <h3>Value</h3> <p><code>read.socket</code> returns the string read as a length-one character vector. </p> <p><code>write.socket</code> returns the number of bytes written. </p> <h3>Author(s)</h3> <p>Thomas Lumley</p> <h3>See Also</h3> <p><code><a href="close.socket.html">close.socket</a></code>, <code><a href="make.socket.html">make.socket</a></code> </p> <h3>Examples</h3> <pre> finger <- function(user, host = "localhost", port = 79, print = TRUE) { if (!is.character(user)) stop("user name must be a string") user <- paste(user,"\r\n") socket <- make.socket(host, port) on.exit(close.socket(socket)) write.socket(socket, user) output <- character(0) repeat{ ss <- read.socket(socket) if (ss == "") break output <- paste(output, ss) } close.socket(socket) if (print) cat(output) invisible(output) } ## Not run: finger("root") ## only works if your site provides a finger daemon ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>