rpcgen(1)rpcgen(1)NAMErpcgen - an RPC protocol compiler
SYNOPSIS
[ ] [ ] [ ] [ name [ = value ] ]
[ ] [ [ ] ] [ ]
[ ] [ ] [ ] [ ] [ ] infile
[ | | | | | | | ]
[ ] [ infile ]
[ ] [ ] [ ] [ infile ]
[ ] [ ] [ ] [ infile ]
DESCRIPTION
is a tool that generates C code to implement an RPC protocol. The
input to is a language similar to C known as RPC Language (Remote Pro‐
cedure Call Language).
is normally used as in the first synopsis where it takes an input file
and generates three output files. If the infile is named then gener‐
ates a header in XDR routines in server-side stubs in and client-side
stubs in With the option, it also generates the RPC dispatch table in
can also generate sample client and server files that can be customized
to suit a particular application. The and options generate sample
client, server and makefile, respectively. The option generates all
files, including sample files. If the infile is then the client side
sample file is written to the server side sample file to and the sample
makefile to
The server created can be started both by the port monitors (for exam‐
ple, or or by itself. When it is started by a port monitor, it creates
servers only for the transport for which the file descriptor was
passed. The name of the transport must be specified by setting up the
environment variable When the server generated by is executed, it cre‐
ates server handles for all the transports specified in environment
variable, or if it is unset, it creates server handles for all the vis‐
ible transports from file. Note: the transports are chosen at run time
and not at compile time. When the server is self-started, it back‐
grounds itself by default. A special define symbol can be used to run
the server process in foreground.
The second synopsis provides special features which allow for the cre‐
ation of more sophisticated RPC servers. These features include sup‐
port for user provided and RPC dispatch tables. The entries in the RPC
dispatch table contain:
· pointers to the service routine corresponding to that proce‐
dure,
· a pointer to the input and output arguments
· the size of these routines
A server can use the dispatch table to check authorization and then to
execute the service routine; a client library may use it to deal with
the details of storage management and XDR data conversion.
The other three synopses shown above are used when one does not want to
generate all the output files, but only a particular one. See the sec‐
tion below for examples of usage. When is executed with the option, it
creates servers for that particular class of transports. When executed
with the option, it creates a server for the transport specified by
netid. If infile is not specified, accepts the standard input.
The C preprocessor, is run on the input file before it is actually
interpreted by For each type of output file, defines a special pre‐
processor symbol for use by the programmer:
defined when compiling into headers
defined when compiling into XDR routines
defined when compiling into server-side stubs
defined when compiling into client-side stubs
defined when compiling into RPC dispatch tables
Any line beginning with ``%'' is passed directly into the output file,
uninterpreted by To specify the path name of the C preprocessor use -Y
flag.
For every data type referred to in infile, assumes that there exists a
routine with the string prepended to the name of the data type. If
this routine does not exist in the RPC/XDR library, it must be pro‐
vided. Providing an undefined data type allows customization of XDR
routines.
Options
Generate all files, including sample files.
Backward compatibility mode.
Generate transport specific RPC code for older versions
of the operating system.
Compile into XDR routines.
Generate header and stub files which can be used with
ANSI C compilers. Headers generated with this flag can
also be used with C++ programs.
Define a symbol
name. Equivalent to the directive in the source. If no
value is given, value is defined as This option may be
specified more than once.
Compile into data-definitions (a header). option can be used in con‐
junction to produce a header which supports RPC dispatch
tables.
Size at which to start generating inline code.
This option is useful for optimization. The default
size is 5.
Compile support for
inetd(1M) in the server side stubs. Such servers can be
self-started or can be started by When the server is
self-started, it backgrounds itself by default. A spe‐
cial define symbol can be used to run the server process
in foreground, or the user may simply compile without
the option.
If there are no pending client requests, the servers
exit after 120 seconds (default). The default can be
changed with the option. All of the error messages for
servers are always logged with syslog(3C).
Note: This option is supported for backward compatibil‐
ity only. It should always be used in conjunction with
the option which generates backward compatibility code.
By default (i.e., when is not specified), generates
servers that can be invoked through portmonitors.
By default, services created using rpcgen and invoked through
port monitors wait seconds after servicing a request
before exiting. That interval can be changed using the
flag. To create a server that exits immediately upon
servicing a request, use To create a server that never
exits, the appropriate argument is
When monitoring for a server, some portmonitors, like
spawn a new process in response to a service request.
If it is known that a server will be used with such a
monitor, the server should exit immediately on comple‐
tion. For such servers, should be used with
Compile into client-side stubs.
When the servers are started in foreground, use
syslog(3C) to log the server errors instead of printing
them on the standard error.
Compile into server-side stubs,
but do not generate a main routine. This option is use‐
ful for doing callback-routines and for users who need
to write their own main routine to do initialization.
Generate multithread-safe stubs for passing arguments and results
between
rpcgen generated code and user written code. This option
is useful for users who want to use threads in their
code.
This option allows procedures to have multiple arguments.
It also uses the style of parameter passing that closely
resembles C. So, when passing an argument to a remote
procedure, you do not have to pass a pointer to the
argument, but can pass the argument itself. This behav‐
ior is different from the old style of generated code.
To maintain backward compatibility, this option is not
the default.
Compile into server-side stubs for the transport
specified by netid. There should be an entry for netid
in the database. This option may be specified more than
once, so as to compile a server that serves multiple
transports.
Specify the name of the output file.
If none is specified, standard output is used (and modes
only).
Compile into server-side stubs for all the
transports belonging to the class nettype. The sup‐
ported classes are and (see rpc(3N) for the meanings
associated with these classes). This option may be
specified more than once. Note: the transports are cho‐
sen at run time and not at compile time.
Generate sample client code that uses remote procedure calls.
Generate a sample Makefile which can be used for compiling the
application.
Generate sample server code that uses remote procedure calls.
Compile into RPC dispatch table.
Generate the code to support RPC dispatch tables.
The options and are used exclusively to generate a par‐
ticular type of file, while the options and are global
and can be used with the other options.
When the server-side stub is produced,
additional code to handle signals is generated. On
reception of a signal, this signal handler code unmaps
the server program from the port mapper before the
server terminates. This code is added only if a routine
is produced in the server-side stub. The option must
not be specified with the options. The following sig‐
nals are trapped: and
Give the name of the directory where
will start looking for the C-preprocessor.
EXAMPLES
The following example:
generates all the five files: and
The following example sends the C data-definitions (header) to the
standard output.
To send the test version of the server side stubs for all the transport
belonging to the class to standard output, use:
To create the server side stubs for the transport indicated by netid
use:
AUTHOR
was developed by Sun Microsystems, Inc.
SEE ALSOcc_bundled(1), inetd(1M), syslog(3C), rpc(3N), rpc_svc_calls(3N).
rpcgen(1)