Robert D. Bowers
2016-Apr-09 16:11 UTC
[R] Solution to communicating with UDP and other interfaces (under Linux) using R
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. Bob
boB Rudis
2016-Apr-09 17:45 UTC
[R] Solution to communicating with UDP and other interfaces (under Linux) using R
Hey Bob, If you're interested, I'd be glad to see what I can do to make doing UDP comms from R accessible across platforms without the need for a `system()` call. Mind shooting me a private e-mail to see what your needs are so I can try to generalize a solution from them? -Bob On Sat, Apr 9, 2016 at 12:11 PM, Robert D. Bowers <n4fbz at tampabay.rr.com> wrote:> 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. > > Bob > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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.