26 lines
1.4 KiB
Plaintext
26 lines
1.4 KiB
Plaintext
\documentclass[letter]{article}
|
|
%\VignetteIndexEntry{JSON RPC server for R}
|
|
%\VignettePackage{rjson}
|
|
|
|
|
|
\begin{document}
|
|
|
|
\title{JSON RPC server for R}
|
|
\author{Alex Couture-Beil}
|
|
\maketitle
|
|
|
|
\section{Introduction}
|
|
|
|
Remote proceedure calls (RPC) provide inter-process communication which allow programs to call other program's subroutines. JSON-RPC is a RPC protocol built on top of JSON.
|
|
JSON-RPC provides a nice way to interface different languages. Sample code for creating an JSON-RPC server for R is supplied with the rjson library. For this example,
|
|
a client wishing to execute R code will first execute a new instance of R, and will communicate over standard IO (stdin/stdout). After the client executes any number of calls, it will terminate the R session with an end of file (ctrl-D).
|
|
|
|
\section{Sample Code}
|
|
|
|
Sample code can be found in the {\it ..../library/rjson/rpc\_server} directory. The server is started with {\it ./start\_server} (unix), or with {\it start\_server.bat} (windows).
|
|
An optional paramater specifies a user supplied source file to be loaded by the server, thus allowing the client to execute some user supplied functions.
|
|
|
|
Note that this code posses serious security risks if the client accecpts input from anyone. (i.e. the client redirects IO from some tcp port to the R json-rpc interface). If this is the case, you'll likely want to avoid allowing anyone to pass anything to eval.
|
|
|
|
\end{document}
|