From simon.urbanek at r-project.org  Thu Oct 20 00:05:42 2005
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Thu, 20 Oct 2005 00:05:42 +0200
Subject: [Rd] Socks under R
In-Reply-To: <43564A3E.90402@sun.ac.za>
References: <43564A3E.90402@sun.ac.za>
Message-ID: <407EAD0C-EC82-4EBB-A535-85B1E916027B@r-project.org>

Rainer,

On Oct 19, 2005, at 3:29 PM, Rainer M. Krug wrote:

> when I use
>
> con1 <- socketConnection(...)
>
> in R and want to send text from another application written in  
> Delphi to  R, do I just have to send the text or do I have to  
> implement more control characters and so on?

Sockets are just reliable bi-directional communication channels (in  
the default mode), so their use is entirely up to you (both on R side  
and other application's side).

> Is
>
> con1 <- socketConnection(port=6011, server=TRUE)
> writeLines("plot(rnorm(100))", con1)
>
> just sending the text in "plot(rnorm(100))" to the socket or is it  
> doing more (R specific protocoll for socks comminication)?

It basically equivalent to using "send" on the socket API level [i.e.  
the above effectively does send(s, "plot(rnorm(100))\n", 17, 0)], so  
it's up to the other side to receive it properly. There is no "R  
specific protocol" - socket connections in R use regular TCP (neither  
red nor white "socks" ;)), so the literature on socket programming is  
your friend (e.g. using readLines(con1) for incoming traffic in your  
example would be a bad idea).

Cheers,
Simon



[Rd] Socks under R
Simon Urbanek