OK, I figured this out:

> s <- "CONNECT\n\n"
> con <- socketConnection(port=61613, blocking=F)
> writeChar(s, con, nchar(s))
> r = readLines(con)
> r
[1] "CONNECTED"
 "session:ID:yourhost.yourdomain.com-49763-1276709732624-4:28" ""

[4] ""
> close(con)

Thanks
Dan



On Wed, Jun 16, 2010 at 12:52 PM, Dan Tenenbaum <
dtenenbaum@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]]

