# man > rpcgen(1)

[rpcgen(1)](https://www.chedong.com/phpMan.php/man/rpcgen/1/markdown)                              General Commands Manual                             [rpcgen(1)](https://www.chedong.com/phpMan.php/man/rpcgen/1/markdown)



## NAME
       _r_r_p_p_c_c_g_g_e_e_n_n - an RPC protocol compiler

## SYNOPSIS
       _r_r_p_p_c_c_g_g_e_e_n_n _infile_
       _r_r_p_p_c_c_g_g_e_e_n_n _[_[_-_-_D_D_name[_[_=_=_value]_]_]_] _[_[_-_-_T_T_]_] _[_[_-_-_K_K _secs]_] _infile_
       _r_r_p_p_c_c_g_g_e_e_n_n _-_-_c_c_|_|_-_-_h_h_|_|_-_-_l_l_|_|_-_-_m_m_|_|_-_-_M_M_|_|_-_-_t_t _[_[_-_-_o_o _outfile_ _]_] _infile_
       _r_r_p_p_c_c_g_g_e_e_n_n _[_[_-_-_I_I_]_] _-_-_s_s _nettype_ _[_[_-_-_o_o _outfile]_] _infile_
       _r_r_p_p_c_c_g_g_e_e_n_n _-_-_n_n _netid_ _[_[_-_-_o_o _outfile]_] _infile_

## DESCRIPTION
       _r_r_p_p_c_c_g_g_e_e_n_n  is a tool that generates C code to implement an RPC protocol.  The input to _r_r_p_p_c_c_g_g_e_e_n_n is
       a language similar to C known as RPC Language (Remote Procedure Call Language).

       _r_r_p_p_c_c_g_g_e_e_n_n is normally used as in the first synopsis where it takes an input file  and  generates
       up  to four output files.  If the _infile_ is named _p_p_r_r_o_o_t_t_o_o_._._x_x, then _r_r_p_p_c_c_g_g_e_e_n_n will generate a header
       file in _p_p_r_r_o_o_t_t_o_o_._._h_h, XDR routines in _p_p_r_r_o_o_t_t_o_o_____x_x_d_d_r_r_._._c_c, server-side stubs in _p_p_r_r_o_o_t_t_o_o_____s_s_v_v_c_c_._._c_c,  and  client-
       side stubs in _p_p_r_r_o_o_t_t_o_o_____c_c_l_l_n_n_t_t_._._c_c.  With the _-_-_T_T option, it will also generate the RPC dispatch table
       in _p_p_r_r_o_o_t_t_o_o_____t_t_b_b_l_l_._._i_i.  With the _-_-_S_S_c_c option, it will also generate  sample code which  would  illus‐
       trate  how  to  use  the  remote procedures on the client side. This code would be created in
       _p_p_r_r_o_o_t_t_o_o_____c_c_l_l_i_i_e_e_n_n_t_t_._._c_c.  With the _-_-_S_S_s_s option, it will also generate a sample server code which  would
       illustrate how to write the remote procedures. This code would be created in _p_p_r_r_o_o_t_t_o_o_____s_s_e_e_r_r_v_v_e_e_r_r_._._c_c.

       The server created can be started both by the port monitors (for example, _i_i_n_n_e_e_t_t_d_d or _l_l_i_i_s_s_t_t_e_e_n_n) or
       by itself.  When it is started by a port monitor, it creates servers only for  the  transport
       for  which  the file descriptor _0_0 was passed.  The name of the transport must be specified by
       setting up the environmental variable _P_P_M_M_____T_T_R_R_A_A_N_N_S_S_P_P_O_O_R_R_T_T.  When the server generated by  _r_r_p_p_c_c_g_g_e_e_n_n  is
       executed,  it  creates server handles for all the transports specified in _N_N_E_E_T_T_P_P_A_A_T_T_H_H environment
       variable, or if it is unset, it creates server handles for all the  visible  transports  from
       _/_/_e_e_t_t_c_c_/_/_n_n_e_e_t_t_c_c_o_o_n_n_f_f_i_i_g_g file.  Note: the transports are chosen at run time and not at compile time.

       When  built  for  a  port  monitor (_r_r_p_p_c_c_g_g_e_e_n_n _-_-_I_I), and that the server is self-started, it back‐
       grounds itself by default.  A special define symbol _R_R_P_P_C_C_____S_S_V_V_C_C_____F_F_G_G can be used to run the  server
       process in foreground.

       The  second synopsis provides special features which allow for the creation of more sophisti‐
       cated RPC servers.  These features include support for user provided _#_#_d_d_e_e_f_f_i_i_n_n_e_e_s_s  and  RPC  dis‐
       patch tables.  The entries in the RPC dispatch table contain:
              •  pointers to the service routine corresponding to that procedure,
              •  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 out‐
       put files, but only a particular one.  Some examples of their usage is described in the EXAM‐
       PLE  section  below.  When _r_r_p_p_c_c_g_g_e_e_n_n is executed with the _-_-_s_s option, it creates servers for that
       particular class of transports.  When executed with the _-_-_n_n option, it creates  a  server  for
       the  transport  specified  by _netid_.  If _infile_ is not specified, _r_r_p_p_c_c_g_g_e_e_n_n accepts the standard
       input.

       The C preprocessor, _c_c_c_c _-_-_E_E [see [_c_c_c_c(1)](https://www.chedong.com/phpMan.php/man/cccc/1/markdown)], is run on the input file before it is actually  inter‐
       preted by _r_r_p_p_c_c_g_g_e_e_n_n.  For each type of output file, _r_r_p_p_c_c_g_g_e_e_n_n defines a special preprocessor symbol
       for use by the _r_r_p_p_c_c_g_g_e_e_n_n programmer:

       _R_R_P_P_C_C_____H_H_D_D_R_R     defined when compiling into header files
       _R_R_P_P_C_C_____X_X_D_D_R_R     defined when compiling into XDR routines
       _R_R_P_P_C_C_____S_S_V_V_C_C     defined when compiling into server-side stubs
       _R_R_P_P_C_C_____C_C_L_L_N_N_T_T    defined when compiling into client-side stubs
       _R_R_P_P_C_C_____T_T_B_B_L_L     defined when compiling into RPC dispatch tables

       Any line beginning with `_%_%' is passed directly into the output file, uninterpreted by _r_r_p_p_c_c_g_g_e_e_n_n.

       For every data type referred to in _infile_, _r_r_p_p_c_c_g_g_e_e_n_n assumes that there exists  a  routine  with
       the  string  _x_x_d_d_r_r____  prepended to the name of the data type.  If this routine does not exist in
       the RPC/XDR library, it must be provided.  Providing an undefined data type allows customiza‐
       tion of XDR routines.

       The following options are available:

       _-_-_a_a     Generate all the files including sample code for client and server side.

       _-_-_b_b     This  generates  code for the SunOS4.1 style of rpc. It is for backward compatibility.
              This is the default.

       _-_-_5_5     This generates code for the SysVr4 style of rpc. It is used by the Transport  Indepen‐
              dent RPC that is in Svr4 systems.  By default rpcgen generates code for SunOS4.1 stype
              of rpc.

       _-_-_c_c     Compile into XDR routines.

       _-_-_C_C     Generate code in ANSI C. This option also generates code that could be  compiled  with
              the C++ compiler.  This is the default.

       _-_-_k_k     Generate code in K&R C.  The default is ANSI C.

       _-_-_D_D_name[_[_=_=_value]_]
              Define a symbol _name_.  Equivalent to the _#_#_d_d_e_e_f_f_i_i_n_n_e_e directive in the source.  If no _value_
              is given, _value_ is defined as _1_1.  This option may be specified more than once.

       _-_-_h_h     Compile into _C_C data-definitions (a header file).  _-_-_T_T option can be used in conjunction
              to produce a header file which supports RPC dispatch tables.

       _-_-_I_I     Generate  a  service  that  can  be  started from inetd.  The default is to generate a
              static service that handles transports selected with _-_-_s_s.  Using _-_-_I_I allows  starting  a
              service by either method.

       _-_-_K_K _secs_
              By  default,  services created using _r_r_p_p_c_c_g_g_e_e_n_n wait _1_1_2_2_0_0 seconds after servicing a request
              before exiting.  That interval can be changed using the _-_-_K_K flag.  To create  a  server
              that exits immediately upon servicing a request, _-_-_K_K _0_0 can be used.  To create a server
              that never exits, the appropriate argument is _-_-_K_K _-_-_1_1.

              When monitoring for a server, some portmonitors, like [_l_l_i_i_s_s_t_t_e_e_n_n(1M)](https://www.chedong.com/phpMan.php/man/lliisstteenn/1M/markdown), _always_ 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  completion.   For  such
              servers, _r_r_p_p_c_c_g_g_e_e_n_n should be used with _-_-_K_K _-_-_1_1.

       _-_-_l_l     Compile into client-side stubs.

       _-_-_m_m     Compile  into server-side stubs, but do not generate a “main” routine.  This option is
              useful for doing callback-routines and for users who need to write  their  own  “main”
              routine to do initialization.

       _-_-_M_M     Generate  multithread-safe stubs for passing arguments and results between rpcgen-gen‐
              erated code and user written code.  This option is useful for users who  want  to  use
              threads in their code.

       _-_-_n_n _netid_
              Compile  into server-side stubs for the transport specified by _netid_.  There should be
              an entry for _netid_ in the netconfig database.  This option may be specified more  than
              once, so as to compile a server that serves multiple transports.

       _-_-_N_N     Use  the  newstyle  of  rpcgen. This 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
              the argument itself. This behaviour is different from the oldstyle of rpcgen generated
              code. The newstyle is not the default case because of backward compatibility.

       _-_-_o_o _outfile_
              Specify  the  name  of the output file.  If none is specified, standard output is used
              (_-_-_c_c, _-_-_h_h, _-_-_l_l, _-_-_m_m, _-_-_n_n, _-_-_s_s, _-_-_S_S_c_c, _-_-_S_S_m_m, _-_-_S_S_s_s, and _-_-_t_t modes only).

       _-_-_s_s _nettype_
              Compile into server-side stubs for all the transports belonging to the class  _nettype_.
              The  supported  classes  are _n_n_e_e_t_t_p_p_a_a_t_t_h_h, _v_v_i_i_s_s_i_i_b_b_l_l_e_e, _c_c_i_i_r_r_c_c_u_u_i_i_t_t_____n_n, _c_c_i_i_r_r_c_c_u_u_i_i_t_t_____v_v, _d_d_a_a_t_t_a_a_g_g_r_r_a_a_m_m_____n_n, _d_d_a_a_t_t_a_a_‐‐
              _g_g_r_r_a_a_m_m_____v_v, _t_t_c_c_p_p, and _u_u_d_d_p_p [see [_r_r_p_p_c_c(3N)](https://www.chedong.com/phpMan.php/man/rrppcc/3N/markdown) 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.

       _-_-_S_S_c_c    Generate sample code to show the use of remote procedure and how to bind to the server
              before calling the client side stubs generated by rpcgen.

       _-_-_S_S_m_m    Generate a sample Makefile which can be used for compiling the application.

       _-_-_S_S_s_s    Generate skeleton code for the remote procedures on the server side. You would need to
              fill in the actual code for the remote procedures.

       _-_-_t_t     Compile into RPC dispatch table.

       _-_-_T_T     Generate the code to support RPC dispatch tables.

       The options _-_-_c_c, _-_-_h_h, _-_-_l_l, _-_-_m_m, _-_-_s_s and _-_-_t_t are used exclusively to generate a particular  type  of
       file, while the options _-_-_D_D and _-_-_T_T are global and can be used with the other options.

## NOTES
       The RPC Language does not support nesting of structures.  As a work-around, structures can be
       declared at the top-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.  Most of these can be avoided by giving unique names  for  programs,  versions,
       procedures and types.

       The server code generated with _-_-_n_n option refers to the transport indicated by _netid_ and hence
       is very site specific.

## EXAMPLE
       The following example:

              _$_$ _r_r_p_p_c_c_g_g_e_e_n_n _-_-_T_T _p_p_r_r_o_o_t_t_._._x_x

       generates the five files: _p_p_r_r_o_o_t_t_._._h_h, _p_p_r_r_o_o_t_t_____c_c_l_l_n_n_t_t_._._c_c, _p_p_r_r_o_o_t_t_____s_s_v_v_c_c_._._c_c, _p_p_r_r_o_o_t_t_____x_x_d_d_r_r_._._c_c and _p_p_r_r_o_o_t_t_____t_t_b_b_l_l_._._i_i.

       The following example sends the C data-definitions (header file) to the standard output.

              _$_$ _r_r_p_p_c_c_g_g_e_e_n_n _-_-_h_h _p_p_r_r_o_o_t_t_._._x_x

       To send the test version of the _-_-_D_D_T_T_E_E_S_S_T_T, server side stubs for all the transport belonging  to
       the class _d_d_a_a_t_t_a_a_g_g_r_r_a_a_m_m_____n_n to standard output, use:

              _$_$ _r_r_p_p_c_c_g_g_e_e_n_n _-_-_s_s _d_d_a_a_t_t_a_a_g_g_r_r_a_a_m_m_____n_n _-_-_D_D_T_T_E_E_S_S_T_T _p_p_r_r_o_o_t_t_._._x_x

       To create the server side stubs for the transport indicated by _netid_ _t_t_c_c_p_p, use:

              _$_$ _r_r_p_p_c_c_g_g_e_e_n_n _-_-_n_n _t_t_c_c_p_p _-_-_o_o _p_p_r_r_o_o_t_t_____s_s_v_v_c_c_._._c_c _p_p_r_r_o_o_t_t_._._x_x

## SEE ALSO
       [_c_c_c_c(1)](https://www.chedong.com/phpMan.php/man/cccc/1/markdown).



                                                                                                  0a
