read.socket package:utils R Documentation _R_e_a_d _f_r_o_m _o_r _W_r_i_t_e _t_o _a _S_o_c_k_e_t _D_e_s_c_r_i_p_t_i_o_n: 'read.socket' reads a string from the specified socket, 'write.socket' writes to the specified socket. There is very little error checking done by either. _U_s_a_g_e: read.socket(socket, maxlen = 256, loop = FALSE) write.socket(socket, string) _A_r_g_u_m_e_n_t_s: socket: a socket object maxlen: maximum length of string to read loop: wait for ever if there is nothing to read? string: string to write to socket _V_a_l_u_e: 'read.socket' returns the string read. _A_u_t_h_o_r(_s): Thomas Lumley _S_e_e _A_l_s_o: 'close.socket', 'make.socket' _E_x_a_m_p_l_e_s: 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)