[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 4

rpcgen Command

Purpose

Generates C code to implement an RPC protocol.

Syntax

To Generate Four Types of Output Files for a File

/usr/bin/rpcgen InputFile

To Generate a Specific Output File for a File

rpcgen-c | -h | -l | -m } [ -o OutputFile ] [ InputFile ]

To Generate a Server-Side File for TCP or UDP

rpcgen-s Transport ... } [ -o OutputFile ] [ InputFile ]

Description

The rpcgen command generates C code to implement a Remote Procedure Call (RPC) protocol. The input to the rpcgen command is a language similar to C language known as RPC Language.

The first syntax structure is the most commonly used form for the rpcgen command where it takes an input file and generates four output files. For example, if the InputFile parameter is named proto.x, then the rpcgen command generates the following:

proto.h Header file
proto_xdr.c XDR routines
proto_svc.c Server-side stubs
proto_clnt.c Client-side stubs

Use the other syntax structures when you want to generate a particular output file rather than all four output files.

The cpp command, a C preprocessor, is run on all input files before they are actually interpreted by the rpcgen command. Therefore, all the cpp directives are legal within an rpcgen input file. For each type of output file, the rpcgen command defines a special cpp symbol for use by the rpcgen programmer:

RPC_HDR Defined when compiling into header files
RPC_XDR Defined when compiling into XDR routines
RPC_SVC Defined when compiling into server-side stubs
RPC_CLNT Defined when compiling into client-side stubs

In addition, the rpcgen command does some preprocessing of its own. Any line beginning with a % (percent sign) passes directly into the output file, uninterpreted by the rpcgen command.

To create your own XDR routines, leave the data types undefined. For every data type that is undefined, the rpcgen command assumes that a routine exists by prepending xdr_ to the name of the undefined type.

Notes:
  1. Nesting is not supported. As a work-around, structures can be declared at top-level with their names used inside other structures in order to achieve the same effect.
  2. Name clashes can occur when using program definitions since the apparent scoping does not really apply. Most of these can be avoided by giving unique names for programs, versions, procedures, and types.
  3. To program to the TIRPC interfaces, and allow the use of multi-threaded RPC applications use the tirpcgen command. It will also be necessary to define the preprocessor variable _AIX_TIRPC in the Makefile as well as the libtli.a (-ltli) specification. tirpcgen is a temporary name for a new rpcgen command that will replace rpcgen in a future version the operating system.

Flags

-c Compiles into XDR routines.
-h Compiles into C-data definitions (a header file).
-l Compiles into client-side stubs.
-m Compiles into server-side stubs, but does not generate a main routine. This option is useful for doing call-back routines and for writing a main routine to do initialization.
-o OutputFile Specifies the name of the output file. If none is specified, standard output is used.
-s Transport Compiles into server-side stubs, using given transport. The supported transports are udp and tcp. This flag can be run more than once to compile a server that serves multiple transports.

Related Information

The cpp command.

Network File System (NFS) Overview for System Management in AIX 5L Version 5.2 System Management Guide: Communications and Networks.

Remote Procedure Call (RPC) Overview for Programming in AIX 5L Version 5.2 Communications Programming Concepts.

List of NFS Commands.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]