[R] Writing a Long across the network?

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Dec 12 07:18:19 CET 2008


On Fri, 12 Dec 2008, Saptarshi Guha wrote:

> Hello,
> 	I have to write  single Long to a server written in java. The server
> passes the input as
>
> 	in.readLong() // it expects to receive 8 bytes
>
> 	In Python, i can do it by sending struct.pack( "!q", value)
>
> 	However, I have tried this
> 	writeBin(length(x),con=conn,endian="big") #conn opened in binary
>
> 	But the response on the server side is wrong, eg. 1 is received as
> 4294967297
>
> 	How do I then write  long across the network from R?

Tell writeBin() the 'size' you want: see its help page.


>
> 	Thank you
> 	Saptarshi
>
>
> Saptarshi Guha | saptarshi.guha at gmail.com | http://www.stat.purdue.edu/~sguha
>
>
>
> 	[[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.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list