sendSocketObject {fame} | R Documentation |
These functions allow R sessions on different machines to send R objects to each other. Consider two R sessions running on (possibly) different machines. Call the sessions R1 and R2, with R1 running on somehost.somewhere.com. To send an object from R1 to R2, the sequence of events goes like this:
1. R1 invokes receiveSocketObject(NNNNN)
, where NNNNN is an
available port number on R1's localhost. (Use
availablePort
to find a port number.) The R1
session hangs until:
2. R2 invokes sendSocketObject(object, "somehost.somewhere.com", NNNNN)
to send object
to R1. If R1 is not listening on port NNNNN
already, this operation will hang R2 until R1 invokes
receiveSocketObject(NNNNN)
to start listening there.
3. R1 and R2 both return after object
has been sent, with
receiveSocketObject
on R1 returning the object that was sent.
sendSocketObject(object, host, port) receiveSocketObject(port)
object |
an R object |
host |
DNS name of the host to which object is being sent |
port |
TCP port number on the receiving end |
sendSocketObject
opens a blocking binary client socket
connection to the given host
and port
, serializes
object
onto the connection, then closes it.
receiveSocketObject
listens on a blocking binary server socket
and returns the R object sent over it.
receiveSocketObject()
returns the object sent.
serialize
puts object
on the socketConnection, while
code{unserialize} reads it at the other end.
Jeff Hallman
availablePort
to find a port number, and
startRemoteServer
to run a server that accepts R commands
over a socket and returns the resulting R objects