To make use of the IDL RPC functionality, you will need to do the following:

  • Include the file idl_rpc.h in your application.
  • Have a copy of idl_export.h in the include path when you compile the client application.
  • Link your client application to the IDL client shared object library (libidl_rpc).
  • If the client library is linked as a shared object, you must set the LD_LIBRARY_PATH environment variable so that it includes the directory that contains the IDL client library. If this variable is not set correctly, an error message will be issued by the system loader when the client program is started.

The command used to compile and link a client program to the IDL RPC client library follows the following format:

% cc -o example $(PRE_FLAGS) example.o -lidl_rpc

where PRE_FLAGS and POST_FLAGS are platform dependent. The proper flags for each UNIX operating system supported by IDL are contained in the file Makefile, located in the in the rpc subdirectory of the external subdirectory of the main IDL directory.

Example of IDL RPC Client API

To use the IDL client side API, execute the following sequence of steps:

  1. Call IDL_RPCInit() to connect to the server
  2. Perform actions on the server—get and set variables, run IDL commands, etc.
  3. Call IDL_RPCCleanup() to disconnect from the server.

Note: The IDL_RPC_InitWithLoopback function should be called if the client needs to connect to an RPC server that is registered with the loopback interface.

The code shown in the following figure is an example that can be used to set up a remote session of IDL using the RPC features. Note that this C program will need to be linked against the supplied shared library libidl_rpc. This code is included in the idldir/external/rpc directory as example.c.


#include "idl_rpc.h" int main()
  CLIENT *pClient;
  char	cmdBuffer[512];
  int	result;
  /* Connect to the server */
  if( (pClient = IDL_RPCInit(0, (char*)NULL)) == (CLIENT*)NULL){ fprintf(stderr, "Can't register with IDL server\n"); exit(1);
  /* Start a loop that will read commands and then send them to idl */
  printf("RMTIDL> "); cmdBuffer[0]='\0'; gets(cmdBuffer);
  if( cmdBuffer[0] == '\n' || cmdBuffer[0] == '\0')
  result = IDL_RPCExecuteStr(pClient, cmdBuffer);
  /* Now disconnect from the server and kill it. */
  if(!IDL_RPCCleanup(pClient, 1))
     fprintf(stderr, "IDL_RPCCleanup: failed\n");

Compile example.c with the appropriate flags for your platform, as described in Linking to the Client Library. Once this example is compiled, execute it using the following commands:

% idlrpc

Then, in another process:

% example