EVOLUTION-MANAGER
Edit File: make.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: Create a Socket Connection</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 make.socket {utils}"><tr><td>make.socket {utils}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Create a Socket Connection</h2> <h3>Description</h3> <p>With <code>server = FALSE</code> attempts to open a client socket to the specified port and host. With <code>server = TRUE</code> the <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> process listens on the specified port for a connection and then returns a server socket. It is a good idea to use <code><a href="../../base/html/on.exit.html">on.exit</a></code> to ensure that a socket is closed, as you only get 64 of them. </p> <h3>Usage</h3> <pre> make.socket(host = "localhost", port, fail = TRUE, server = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>host</code></td> <td> <p>name of remote host</p> </td></tr> <tr valign="top"><td><code>port</code></td> <td> <p>port to connect to/listen on</p> </td></tr> <tr valign="top"><td><code>fail</code></td> <td> <p>failure to connect is an error?</p> </td></tr> <tr valign="top"><td><code>server</code></td> <td> <p>a server socket?</p> </td></tr> </table> <h3>Value</h3> <p>An object of class <code>"socket"</code>, a list with components: </p> <table summary="R valueblock"> <tr valign="top"><td><code>socket</code></td> <td> <p>socket number. This is for internal use. On a Unix-alike it is a file descriptor.</p> </td></tr> <tr valign="top"><td><code>port</code></td> <td> <p>port number of the connection.</p> </td></tr> <tr valign="top"><td><code>host</code></td> <td> <p>name of remote computer.</p> </td></tr> </table> <h3>Warning</h3> <p>I don't know if the connecting host name returned when <code>server = TRUE</code> can be trusted. I suspect not. </p> <h3>Author(s)</h3> <p>Thomas Lumley</p> <h3>References</h3> <p>Adapted from Luke Tierney's code for <code>XLISP-Stat</code>, in turn based on code from Robbins and Robbins “Practical UNIX Programming”. </p> <h3>See Also</h3> <p><code><a href="close.socket.html">close.socket</a></code>, <code><a href="read.socket.html">read.socket</a></code>. </p> <p>Compiling in support for sockets was optional prior to <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> 3.3.0: see <code><a href="../../base/html/capabilities.html">capabilities</a>("sockets")</code> to see if it is available. </p> <h3>Examples</h3> <pre> daytime <- function(host = "localhost"){ a <- make.socket(host, 13) on.exit(close.socket(a)) read.socket(a) } ## Official time (UTC) from US Naval Observatory ## Not run: daytime("tick.usno.navy.mil") </pre> <hr /><div style="text-align: center;">[Package <em>utils</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>