Learn R Programming

svSocket (version 0.9-48)

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, ...)

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
...
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.

See Also

startSocketServer, sendSocketClients, getSocketClients

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 TempEnv
s <- search()
l <- length(s)
pos <- (1:l)[s == "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