Write remote executable program

Here, we'll write a program which calculates the sine on a remote host. We will define the interface of sine function. We name the file which defines interfaces IDL(Interface Description Language) file. The IDL is discussed in detail later section. For example, we can write the calc_sin.idl file as follows.

Module calc_sin;

Globals {
#include <math.h>;
}

Define calc_sin(double IN x, double OUT result[]){
  *result = sin(x);
}
      

Module: We define the module name in the IDL file. In this example, we set this module name as "calc_sin".

Define: Interfaces are defined by the "Define" directive. In this example, we use sin. Arguments are the specified data type and whether the data is input or output. In OmniRPC, we cannot get the return value of the function as a value of the function's value like a original sin function. So, we get the value by specifying arguments as "OUT", as shown in the example. In the part surrounded with {...}, we can write a procedure which is executed on the remote host in C Language. This program calls the sine function and "result", which is an "OUT" argument, returns the since value.

Globals: In the part assigned to "Globals", we can describe any C program which is necessary for functions that are defined in the modules. In this example, the IDL includes files which are required to call the "sin" function.

We can generate a remote executable program from the IDL file by using omrpc-cc, which is OmniRPC's remote executable module generator. So, let's convert using this command. ( "-lm" option is to link math library.)

         % omrpc-cc calc_sin.idl -lm
      

"calc_sin.rex" is generated by executing this program. This is the remote executable program.

By the way, the IDL can define multiple functions in a remote executable module. For Further details, see 13. IDL file Description.