Learn R Programming

svSocket (version 0.9-55)

parSocket: Get or set parameters specific to Sciviews socket clients

Description

This function manage to persistently store sensible parameters for configuring communication between the server and the client, as well as, any other persitent data you may need. Parameters remain set even if the client disconnects and then reconnects to R, as long R was not restarted.

Usage

parSocket(client, serverport = 8888, clientsocket = client, ...)

Arguments

client
the client identification. By default, it is the socket identifier as it appears in getSocketClients(). Since no attempt is made to check if the client really exists and is connected, you can create fake ones, outside of the so
serverport
the port on which the server is running, 8888 by default. Not important for fake socket client configurations.
clientsocket
the Tcl name of the socket where the client is connected. By default, it is the same as client name, but in case it was modified, do provide a correct clientsocket string if you want to be able to activate a redire
...
the parameters you want to change as named arguments. Non named arguments are ignored with a warning. If you specify arg = NULL, the corresponding variable is deleted from the environment.

Value

  • Returns the environment where parameters and data for the client are stored. To access those data, see examples below.

concept

stateful socket server interprocess communication

See Also

startSocketServer, sendSocketClients, getSocketClients, socketClientConnection.

Examples

Run this code
## We use a fake socket client configuration environment
e <- parSocket("fake")
## Look at what it contains
ls(e)
## Get one data
e$bare
## ... or
parSocket("fake")$bare

## Change it
parSocket("fake", bare = FALSE)$bare
## Note it is changed too for e
e$bare

## You can change it too with
e$bare <- TRUE
e$bare
parSocket("fake")$bare

## Create a new entry
e$foo <- "test"
ls(e)
parSocket("fake")$foo
## Now delete it
parSocket("fake", foo = NULL)
ls(e)

## Our fake socket config is in SciViews:TempEnv environment
s <- search()
l <- length(s)
pos <- (1:l)[s == "SciViews:TempEnv"]
ls(pos = pos)  # It is named 'SocketClient_fake'
## Delete it
rm(SocketClient_fake, pos = pos)
## Do some house keeping
rm(list = c("s", "l", "pos"))

Run the code above in your browser using DataLab