Sorry to spam the list again, but I was wondering if anyone has a solution to this. It seems that writing nulls to sockets is a pretty common use case, so I would hope there is a way to do this. Thanks.
On Wed, Jun 16, 2010 at 12:52 PM, Dan Tenenbaum < dtenenb...@systemsbiology.org> wrote: > 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@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.