make.socket               package:base               R Documentation

_C_r_e_a_t_e _a _S_o_c_k_e_t _C_o_n_n_e_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     With `server = FALSE' attempts to open a client socket to the
     specified port and host. With `server = TRUE' listens on the
     specified port for a connection and then returns a server socket.
     It is a good idea to use `on.exit' to ensure that a socket is
     closed, as you only get 64 of them.

_U_s_a_g_e:

     make.socket(host = "localhost", port, fail = TRUE, server = FALSE)
     print.socket(socket)

_A_r_g_u_m_e_n_t_s:

    host: name of remote host

    port: port to connect to/listen on

    fail: failure to connect is an error?

  server: a server socket?

_V_a_l_u_e:

     An object of class `"socket"'. 

  socket: socket number. This is for internal use

    port: port number of the connection

    host: name of remote computer

_W_a_r_n_i_n_g:

     I don't know if the connecting host name returned when `server =
     TRUE' can be trusted. I suspect not.

_A_u_t_h_o_r(_s):

     Thomas Lumley

_R_e_f_e_r_e_n_c_e_s:

     Adapted from Luke Tierney's code for `XLISP-Stat', in turn based
     on code from Robbins and Robbins "Practical UNIX Programming"

_S_e_e _A_l_s_o:

     `close.socket', `read.socket'

_E_x_a_m_p_l_e_s:

     daytime <- function(host = "localhost"){
         a <- make.socket(host, 13)
         on.exit(close.socket(a))
         read.socket(a)
     }
     daytime()  ## only works if your computer runs this service
     daytime("ntp.demon.co.uk")

