2

I am trying to read multiple lines in from a TCP web socket. When I run the following lines one at a time in the RStudio console, I get the data in the expected values and format. When I try to run them together (as part of a larger script or simply by entering both into the console before hitting enter), the NMEA_bulk object reads "character(0)".

    Scon <- socketConnection("127.0.0.1", port = 55555)
    NMEA_bulk <- readLines(Scon, n = 18)

Can someone explain this issue to me? What is the work around?

srs025
  • 88
  • 5
  • This is hardly reproducible. Your question suggests more lines that are relevant to this discussion, and/or there is some other process (R or not) running that is providing usable information. Is there a way to make this question fully-reproducible? – r2evans Jan 30 '20 at 15:59
  • 1
    `socketConnection` defaults to open for *appending* in text mode: `open = "a+"`. You must `open = "rt"` or `"rb"` to *read* from that connection. – Rui Barradas Jan 30 '20 at 16:03

0 Answers0