0

I'm trying to call the load() function on a socketConnection. When I establish the connection (between two R processes), I check the socket info and I see this:

> s <- socketConnection(host = "localhost", 12345, server = FALSE, blocking=TRUE, open = "rb")
> s
        description               class                mode                text
"->localhost:12345"          "sockconn"                "rb"            "binary"
             opened            can read           can write
           "opened"               "yes"               "yes"

The connection was opened successfully and it is readable (and in binary mode). If I now try to read from the socket, I get this:

> load(s)
Error in load(s) : connection not open for reading

Took me a while to figure out why I see the socket saying "can read=yes", while the error message is saying it is not readable. Turns out, the connection is being wrapped with a gzcon object when performing the load(). If I wrap it myself, I see this:

> s
        description               class                mode                text
"->localhost:12345"          "sockconn"                "rb"            "binary"
             opened            can read           can write
           "opened"               "yes"               "yes"
> z <- gzcon(s)
> z
               description                      class
"gzcon(->localhost:12345)"                    "gzcon"
                      mode                       text
                      "rb"                   "binary"
                    opened                   can read
                  "opened"                       "no"
                 can write
                     "yes"
> s
               description                      class
"gzcon(->localhost:12345)"                    "gzcon"
                      mode                       text
                      "rb"                   "binary"
                    opened                   can read
                  "opened"                       "no"
                 can write
                     "yes"

The gzcon converts the connection to unreadable. So my question is, how can I perform a load from a socket, or how I can force gzcon to keep the connection readable?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • So you're new to R and the first thing you're doing is playing with sockets? That seems fairly unusual. What's your ultimate goal here? – MrFlick Jun 13 '14 at 02:43
  • Yes. New to R but got this assignment to transfer a workspace from one process to another. – user3736099 Jun 14 '14 at 09:06

0 Answers0