Programming with OmniRpcHandle API

OmniRpcHandle is a data structure used for connection with a specific remote executable program. Using OmniRpcHandle , you can write programs which keep the status on a remote executable program. And, you can allocate a remote executable program on a specific remote host.

What's OmniRpcHandle
Programming with OmniRpcHandle
Acquisition of host information

What's OmniRpcHandle

OmniRpcHandle is a data structure which presents a connection with a specific remote executable program. OmniRpcHandle is created by activating the remote executable program which corresponds to the module with the OmniRpcCreateHandle API. Once the remote executable program is executing, remote executable programs can accept the requests of another RPC call which is inside of same module, and the program does not need to exit after finishing calculation using a function in the module.

Using this feature, you can do the following.

With OmniRpcCall API, you specify the remote function only, and call the RPCs. From function name, the client program searches for the modules which contain it. Also, on adequate remote hosts remote program can run the remote executable program which corresponds to it, and assign. However if the client program uses OmniRpcHandle API, you should program the host executable module on which the programs are allocated. The host executable module should be allocated on a remote host. However, problems may arise when remote executable modules fail or are unavailable due to a timeout.

Programming with OmniRpcHandle

For an easy example, we show a program which adds values which set the in setAB function and get its value, and use the IDL file as is.

Define Sample;

Globals {
 int a,b;
}

Define setAB(int in a0, int in b0)
{
   a = a0; b = b0;
}

Define plusAB(int out ab[])
{
     *ab = a + b;
}

In the Globals directive, we define, in a style similar to C language, the variables which are used in the whole module. In the Globals scope, we write the module definitions in the style of C language.

You should compile this module with omrpc-cc, and register Sample.rex on the remote host (alice.is.tsukuba.ac.jp).

#include <OmniRpc.h>
#include <stdio.h>

int main(int argc,char *argv[]){
   int ab;
   OmniRpcHandle handle;

   OmniRpcInit(&argc,&argv);
   handle = OmniRpcCreateHandle("alice.is.tsukuba.ac.jp","Sample");

   OmniRpcCallbyHandle(handle,"setAB",10,20);
   OmniRpcCallbyHandle(handle,"plusAB",&ab);
   printf("a+b=%d\n",ab);
  
   OmniRpcHandleDestroy(handle);

   OmniRpcFinalize();
   exit(0);
}

After the modules are initialized, the client program first activates the remote executable programs with OmniRpcCreateHandle API, and gets the OmniRpcHandle corresponding to it. Otherwise, by using OmniRpcCallbyHandle, the client program can call functions in the modules. Finally, the client program can stop the remote executable program with OmniRpcDestroyHandle API.

Also available is OmniRpcCallAsyncByHandle API, which call RPCs asynchronously.

Acquisition of host information.

With OmniRpcCreateHandle API, you specify the remote host name on which the remote executable modules run. However, if you don't, programs allocate the appropriate remote host on modules which are registered.