R socketConnection - 连接未打开以供读取

时间:2014-06-13 02:26:29

标签: r sockets readable

我正试图在load()上调用socketConnection函数。当我建立连接(在两个R进程之间)时,我检查套接字信息,我看到了:

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

连接已成功打开且可读(并且处于二进制模式)。如果我现在尝试从套接字读取,我得到这个:

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

我花了一些时间弄清楚为什么我看到套接字说“可以读取=是”,而错误信息却说它不可读。事实证明,在执行load()时,连接正在用gzcon对象包装。如果我自己包装,我会看到:

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

gzcon将连接转换为不可读。 所以我的问题是,如何从套接字执行加载,或者如何强制gzcon保持连接可读?

0 个答案:

没有答案