"Countchar" rpc call example - source

"countchar()" RPC

This is a somewhat more involved example. The server contains two RPC procedures: one returns the number of times a given character occurs within a given string, and the second returns a linked list of each character in a given string, and its occurence count.

Three versions of a client are shown: one uses clnt_create(), a second does a direct call, and a third an RPC broadcast.

Sample Procedures

  • Makefile - used to compile and link client and server.
  • countchar.x - the rpcgen interface file
  • countchar.h - generated by RPCGEN.
  • countmain.c - the version of the client program that uses the RPCGEN generated client stub.
  • countchar_clnt.c - the client stub generated by RPCGEN.
  • countmain2.c - the version of the client program that uses rpccall() to call the rpc directly.
  • countmain3.c - the broadcast version of the client.
  • countsvcr.c - the server procedure that contains the two procedures countchar_1() and countallchars_1().
  • countchar_svc.c - the server stub (server main program) generated by RPCGEN.