[R] Sending a null byte to a socket

From: Dan Tenenbaum <dtenenbaum_at_systemsbiology.org>
Date: Wed, 16 Jun 2010 12:52:30 -0700


Hello,

I am trying to write some code in R to communicate over sockets via the STOMP protocol (http://stomp.codehaus.org/Protocol).

As you can see, a null byte (ASCII 0) is used as the "over" signal.

I'd like to be able to do something like this:

write.socket(socket, "CONNECT\nlogin: me\npasscode: pass\n\n\000")

However, R does not like it when you put "\000" in a string:
> "\000"

Error: embedded nul in string: '\0'

I thought perhaps that write.socket would automatically send a null byte, but it doesn't appear to.

I'm getting similar results with socketConnection() and writeLines(). I thought that writeBin() might be the solution but it gives me: Error in writeBin(n, con) : can only write to a binary connection

I'm not clear how to make my socket a binary connection.

I am only going to be writing strings, with the exception of these null bytes. Can anyone suggest a method for doing this?

Thanks
Dan

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 16 Jun 2010 - 19:56:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Jun 2010 - 23:00:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive