[R] Solution to communicating with UDP and other interfaces (under Linux) using R
Robert D. Bowers
n4fbz at tampabay.rr.com
Sat Apr 9 18:11:15 CEST 2016
I'd spent hours with Google trying to find how to control a separate
software package from R via a UDP interface (I could run the package
under a "system" command, but that was too slow). I finally figured out
a way to communicate with UDP through R, and it works fine (using the
"system" command) - it's also fast.
(1) install software "socat" (available on most of the Linux
repositories). It's potent software for communication stuff, btw.
(2) set up the UDP 'port' to communicate with (like in a separate
software package for passing commands and responses back and forth).
(3) use the "system" command to send messages - as an example:
system("echo \"quit\"| socat - UDP4-DATAGRAM:0.0.0.0:19004")
I haven't tried receiving data from that software yet... but according
to the writeup on socat, it should be no problem.
You can also use the socat software to redirect from one type of
connection to another.
(I'm studying R - both for programming/running 'real world' interfaces
and then doing the statistics on the data.)
Hope this helps someone - the (tiny) few messages I've found indicated
that it couldn't be done (they were old). It can be done and rather simply.
More information about the R-help