Please consider the following example (using 2 R sessions):
1st R session - R Server
library(svSocket)
startSocketServer()
2nd R session - R Client
library(svSocket)
con <- socketConnection(host = "localhost", port = 8888, blocking = FALSE)
value<-"setosa"
evalServer(con, tmp, value) # first call to the server
evalServer(con, head(iris[iris$Species==tmp,])) # second call to the server
Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1 5.1 3.5 1.4 0.2 setosa
2 4.9 3.0 1.4 0.2 setosa
3 4.7 3.2 1.3 0.2 setosa
4 4.6 3.1 1.5 0.2 setosa
5 5.0 3.6 1.4 0.2 setosa
6 5.4 3.9 1.7 0.4 setosa
To send the above query I need a 2-step process where I first save my parameter in the server and then I use them to query the table.
Problem
Do the same in one step only. For example, building the query using paste
and send it to the server like I would in PHP + MySQL. Basically, I need to avoid that a different user overwrites tmp
between the first and the second call to the server. The above commands will be running behind web apps with 30 to 50 users simultaneously connected, so I reckon that this inconvenience might happen.