Linux "rpcgen" Command Line Options and Examples
an RPC protocol compiler

rpcgen is a tool that generates C code to implement an RPC protocol. The input to rpcgen is a language simi‐ lar to C known as RPC Language (Remote Procedure Call Language). rpcgen is normally used as in the first synopsis where it takes an input file and generates up to four output files.


Usage:

rpcgen infile
rpcgen [-Dname[=value]] [-T] [-K secs] infile
rpcgen -c|-h|-l|-m|-M|-t [-o outfile ] infile
rpcgen [-I] -s nettype [-o outfile] infile
rpcgen -n netid [-o outfile] infile




Command Line Options:

-a
Generate all the files including sample code for client and server side.
rpcgen -a ...
-c
Compile into XDR routines.
rpcgen -c ...
-k
Generate code in K&R C. The default is ANSI C.
rpcgen -k ...
-Dname[
Define a symbol name. Equivalent to the #define directive in the source. If no value is given, valueis defined as 1. This option may be specified more than once.
rpcgen -Dname[ ...
-K
By default, services created using rpcgen wait 120 seconds after servicing a request before exiting.That interval can be changed using the -K flag. To create a server that exits immediately upon servic‐ing a request, -K 0 can be used. To create a server that never exits, the appropriate argument is
rpcgen -K ...
-l
Compile into client-side stubs.
rpcgen -l ...
-n
Compile into server-side stubs for the transport specified by netid. There should be an entry fornetid in the netconfig database. This option may be specified more than once, so as to compile aserver that serves multiple transports.
rpcgen -n ...
-o
Specify the name of the output file. If none is specified, standard output is used (-c, -h, -l, -m,
rpcgen -o ...
-s
Compile into server-side stubs for all the transports belonging to the class nettype. The supportedclasses are netpath, visible, circuit_n, circuit_v, datagram_n, datagram_v, tcp, and udp [see rpc(3N)for the meanings associated with these classes]. This option may be specified more than once. Note:the transports are chosen at run time and not at compile time.
rpcgen -s ...
-Sm
Generate a sample Makefile which can be used for compiling the application.
rpcgen -Sm ...
-t
Compile into RPC dispatch table.
rpcgen -t ...
-T
The options -c, -h, -l, -m, -s and -t are used exclusively to generate a particular type of file, while theoptions -D and -T are global and can be used with the other options.NOTESThe RPC Language does not support nesting of structures. As a work-around, structures can be declared at thetop-level, and their name used inside other structures in order to achieve the same effect.Name clashes can occur when using program definitions, since the apparent scoping does not really apply. Mostof these can be avoided by giving unique names for programs, versions, procedures and types.The server code generated with -n option refers to the transport indicated by netid and hence is very sitespecific.EXAMPLEThe following example:$ rpcgen -T prot.xgenerates the five files: prot.h, prot_clnt.c, prot_svc.c, prot_xdr.c and prot_tbl.i.The following example sends the C data-definitions (header file) to the standard output.$ rpcgen -h prot.xTo send the test version of the -DTEST, server side stubs for all the transport belonging to the class data‐gram_n to standard output, use:$ rpcgen -s datagram_n -DTEST prot.xTo create the server side stubs for the transport indicated by netid tcp, use:$ rpcgen -n tcp -o prot_svc.c prot.x
rpcgen -T ...