Writing a Client Program

This page explains how to write a client program that uses SHRIMP RPC.

First, create an interface definition file, written in SIDL, and run the stub-generator on it to produce an include-file, a client C file, and a server C file.

Assume you're implementing the foo service. After running foo.x through the stub generator, you'll have three files, foo_rpc.h, foo_clnt.c, and foo_serv.c.

Your client program should #include foo_rpc.h. You should compile foo_clnt.c into foo_clnt.o, and link foo_clnt.o with your client program and with the SRPC runtime library, /u/shrimp/lib/libsrpc.a. When compiling, use the -I/u/shrimp/include switch to include the SRPC header files.

Making Remote Calls

Before making remote procedure calls, your client program must obtain a binding to the server. To call the function bar remotely, simply call the function remote_bar; a function prototype for remote_bar should be in foo_rpc.h.

remote_bar should take the same arguments, with the same types, that you declared in your interface definition file foo.x. There is an additional first argument which should be the binding through which you're talking to the server.

Return Codes

The call to remote_bar will return 0 if the remote call was performed, or -1 if the call failed. (Failure usually means the binding was invalid, or that the server didn't exist or was inaccessible.)


Ed Felten