startSocketServer {svSocket}R Documentation

Start and stop a R socket server.

Description

A R socket server is listening for command send by clients to a TCP port. This server is implemented in Tcl/Tk, using the powerful 'socket' command. Since it runs in the separate tcltk event loop, it is not blocking R, and it runs in the background; the user can still enter commands at the R prompt while one or several R socket servers are running and even, possibly, processing socket clients requests.

Usage

startSocketServer(port = 8888, server.name = "Rserver", procfun = processSocket)
stopSocketServer(port = 8888)

Arguments

port The TCP port of the R socket server
server.name The internal name of this server
procfun The function to use to process client's commands. By default, it is processSocket().

Details

One can write a different procfun function than the default one for special servers. That function must accept one argument (a string with the command send by the client) and it must return a character string containing the result of the computation.

Note

This server is currently synchronous in the processing of the command. However, neither R, nor the client are blocked during exchange of data (communication is asynchronous).

Note also that socket numbers are reused, and corresponding configurations are not deleted from one connection to the other. So, it is possible for a client to connect/disconnect several times and continue to work with the same configuration (in particular, the multiline code submitted line by line) if every command starts with <<<id=myID>>> where myID is an alphanumeric (unique) identifier. Take care! The R server never checks uniqueness of this identifier. You are responsible to use one that would not class with other, concurrent, clients on this server.

For trials and basic testings of the R socket server, you can use the Tcl script SimpleClient.Tcl. See the ReadMe.txt file in the /etc/ subdirectory of the svSocket package folder. Also, in the source of the svSocket package you will find testCLI.r, a script to torture test CLI for R (console).

Author(s)

Philippe Grosjean (phgrosjean@sciviews.org)

See Also

processSocket


[Package svSocket version 0.9-43 Index]