Description Usage Arguments Author(s) See Also Examples
The text is send to one or more clients of the R socket server currently connected.
1 | sendSocketClients(text, sockets = "all", serverport = 8888)
|
text |
the text to send to the client(s). |
sockets |
the Tcl name of the client(s) socket(s) currently connected (sockXXX), or "all" (by default) to send the same text to all connected clients. |
serverport |
the port of the server considered. |
Philippe Grosjean (phgrosjean@sciviews.org)
closeSocketClients
, processSocket
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ## Not run:
## Start an R process (R#1) and make it a server
require(svSocket)
serverport <- 8888 # Port 8888 by default, but you can change it
startSocketServer(port = serverport)
## Start a second R process (R#2) and run this code in it (the R client):
require(svSocket)
## Connect with the R socket server
con <- socketConnection(host = "localhost", port = 8888, blocking = FALSE)
## Now, go back to the server R#1
getSocketClients() # You should have one client registered
## Send something to all clients from R#1
sendSocketClients("Hi there!")
## Switch back to client R#2
## Since the connection is not blocking, you have to read lines actively
readLines(con)
## Note the final empty string indicating there is no more data
close(con) # Once done...
## Switch to the R#1 server and close the server
stopSocketServer(port = serverport)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.