Blame | Last modification | View Log | RSS feed
.\" @(#)rpcgen.new.1 1.1 90/11/09 TIRPC 1.0; from 40.10 of 10/10/89.\" Copyright (c) 1988,1990 Sun Microsystems, Inc. - All Rights Reserved..nr X.if \nX=0 .ds x} rpcgen 1 "" "\&".if \nX=1 .ds x} rpcgen 1 "".if \nX=2 .ds x} rpcgen 1 "" "\&".if \nX=3 .ds x} rpcgen "" "" "\&".TH \*(x}.SH NAME\f4rpcgen\f1 \- an RPC protocol compiler.SH SYNOPSIS.ft 4.nfrpcgen \f2infile\f4.fi.ft 1.br.ft 4.nfrpcgen [\-D\f2name\f4[=\f2value\f4]] [\-T] [\-K \f2secs\fP] \f2infile\f4.fi.ft 1.br.ft 4.nfrpcgen \-c|\-h|\-l|\-m|\-t [\-o \f2outfile\f4 ] \f2infile\f4.fi.ft 1.br.ft 4.nfrpcgen \-s \f2nettype\f4 [\-o \f2outfile\f4] \f2infile\f4.fi.ft 1.br.ft 4.nfrpcgen \-n \f2netid\f4 [\-o \f2outfile\f4] \f2infile\f4.ft 1.SH DESCRIPTION.P\f4rpcgen\f1is a tool that generates C code to implement an RPC protocol.The input to\f4rpcgen\f1is a language similar to C known asRPC Language (Remote Procedure Call Language)..P\f4rpcgen\f1is normally used as in the first synopsis whereit takes an input file and generates up to four output files.If the\f2infile\f1is named\f4proto.x\f1,then\f4rpcgen\f1will generate a header file in\f4proto.h\f1,XDR routines in\f4proto_xdr.c\f1,server-side stubs in\f4proto_svc.c\f1,and client-side stubs in\f4proto_clnt.c\f1.With the\f4\-T\f1option,it will also generate the RPC dispatch table in\f4proto_tbl.i\f1.With the\f4\-Sc\f1option,it will also generate sample code which would illustrate how to use theremote procedures on the client side. This code would be created in\f4proto_client.c\f1.With the\f4\-Ss\f1option,it will also generate a sample server code which would illustrate how to writethe remote procedures. This code would be created in\f4proto_server.c\f1..PThe server created can be started both by the port monitors(for example, \f4inetd\f1 or \f4listen\f1)or by itself.When it is started by a port monitor,it creates servers only for the transport for whichthe file descriptor \f40\fP was passed.The name of the transport must be specifiedby setting up the environmental variable\f4PM_TRANSPORT\f1.When the server generated by\f4rpcgen\f1is executed,it creates server handles for all the transportsspecified in\f4NETPATH\f1environment variable,or if it is unset,it creates server handles for all the visible transports from\f4/etc/netconfig\f1file.Note:the transports are chosen at run time and not at compile time.When the server is self-started,it backgrounds itself by default.A special define symbol\f4RPC_SVC_FG\f1can be used to run the server process in foreground..PThe second synopsis provides special features which allowfor the creation of more sophisticated RPC servers.These features include support for user provided\f4#defines\f1and RPC dispatch tables.The entries in the RPC dispatch table contain:.RS.PD 0.TP 3\(bupointers to the service routine corresponding to that procedure,.TP\(bua pointer to the input and output arguments.TP\(buthe size of these routines.PD.REA server can use the dispatch table to check authorizationand then to execute the service routine;a client library may use it to deal with the details of storagemanagement and XDR data conversion..PThe other three synopses shown above are used whenone does not want to generate all the output files,but only a particular one.Some examples of their usage is described in theEXAMPLEsection below.When\f4rpcgen\f1is executed with the\f4\-s\f1option,it creates servers for that particular class of transports.Whenexecuted with the\f4\-n\f1option,it creates a server for the transport specified by\f2netid\f1.If\f2infile\f1is not specified,\f4rpcgen\f1accepts the standard input..PThe C preprocessor,\f4cc \-E\f1[see \f4cc\fP(1)],is run on the input file before it is actually interpreted by\f4rpcgen\f1.For each type of output file,\f4rpcgen\f1defines a special preprocessor symbol for use by the\f4rpcgen\f1programmer:.P.PD 0.TP 12\f4RPC_HDR\f1defined when compiling into header files.TP\f4RPC_XDR\f1defined when compiling into XDR routines.TP\f4RPC_SVC\f1defined when compiling into server-side stubs.TP\f4RPC_CLNT\f1defined when compiling into client-side stubs.TP\f4RPC_TBL\f1defined when compiling into RPC dispatch tables.PD.PAny line beginning with`\f4%\f1'is passed directly into the output file,uninterpreted by\f4rpcgen\f1..PFor every data type referred to in\f2infile\f1,\f4rpcgen\f1assumes that there exists aroutine with the string\f4xdr_\f1prepended to the name of the data type.If this routine does not exist in the RPC/XDRlibrary, it must be provided.Providing an undefined data typeallows customization of XDR routines..br.ne 10.PThe following options are available:.TP\f4\-a\f1Generate all the files including sample code for client and server side..TP\f4\-b\f1This generates code for the SunOS4.1 style of rpc. It is onlyfor backward compatibilty. By default rpcgen generates code forTransport Independent RPC that is in Svr4 systems..TP\f4\-c\f1Compile into XDR routines..TP\f4\-C\f1Generate code in ANSI C. This option also generates code that could becompiled with the C++ compiler..TP\f4\-D\f2name\f4[=\f2value\f4]\f1Define a symbol\f2name\f1.Equivalent to the\f4#define\f1directive in the source.If no\f2value\f1is given,\f2value\f1is defined as \f41\f1.This option may be specified more than once..TP\f4\-h\f1Compile into\f4C\f1data-definitions (a header file).\f4\-T\f1option can be used in conjunction to produce aheader file which supports RPC dispatch tables..TP\f4-K\f2 secs\f1By default, services created using \f4rpcgen\fP wait \f4120\fP secondsafter servicing a request before exiting.That interval can be changed using the \f4-K\fP flag.To create a server that exits immediately upon servicing a request,\f4-K\ 0\fP can be used.To create a server that never exits, the appropriate argument is\f4-K\ -1\fP..IPWhen monitoring for a server,some portmonitors, like\f4listen\fP(1M),.I alwaysspawn a new process in response to a service request.If it is known that a server will be used with such a monitor, theserver should exit immediately on completion.For such servers, \f4rpcgen\fP should be used with \f4-K\ -1\fP..TP\f4\-l\f1Compile into client-side stubs..TP\f4\-m\f1Compile into server-side stubs,but do not generate a \(lqmain\(rq routine.This option is useful for doing callback-routinesand for users who need to write their own\(lqmain\(rq routine to do initialization..TP\f4\-n \f2netid\f1Compile into server-side stubs for the transportspecified by\f2netid\f1.There should be an entry for\f2netid\f1in thenetconfig database.This option may be specified more than once,so as to compile a server that serves multiple transports..TP\f4\-N\f1Use the newstyle of rpcgen. This allows procedures to have multiple arguments.It also uses the style of parameter passing that closely resembles C. So, whenpassing an argument to a remote procedure you do not have to pass a pointer tothe argument but the argument itself. This behaviour is different from the oldstyleof rpcgen generated code. The newstyle is not the default case because ofbackward compatibility..TP\f4\-o \f2outfile\f1Specify the name of the output file.If none is specified,standard output is used(\f4\-c\f1,\f4\-h\f1,\f4\-l\f1,\f4\-m\f1,\f4\-n\f1,\f4\-s\f1,\f4\-s\Sc,\f4\-s\Ssand\f4\-t\f1modes only)..TP\f4\-s \f2nettype\f1Compile into server-side stubs for all thetransports belonging to the class\f2nettype\f1.The supported classes are\f4netpath\f1,\f4visible\f1,\f4circuit_n\f1,\f4circuit_v\f1,\f4datagram_n\f1,\f4datagram_v\f1,\f4tcp\f1,and\f4udp\f1[see \f4rpc\fP(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..TP\f4\-Sc\f1Generate sample code to show the use of remote procedure and how to bindto the server before calling the client side stubs generated by rpcgen..TP\f4\-Ss\f1Generate skeleton code for the remote procedures on the server side. You would needto fill in the actual code for the remote procedures..TP\f4\-t\f1Compile into RPC dispatch table..TP\f4\-T\f1Generate the code to support RPC dispatch tables..PThe options\f4\-c\f1,\f4\-h\f1,\f4\-l\f1,\f4\-m\f1,\f4\-s\f1and\f4\-t\f1are used exclusively to generate a particular type of file,while the options\f4\-D\f1and\f4\-T\f1are global and can be used with the other options..br.ne 5.SH NOTESThe 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 inorder to achieve the same effect..PName clashes can occur when using program definitions,since the apparent scoping does not really apply.Most of these can be avoided by givingunique names for programs,versions,procedures and types..PThe server code generated with\f4\-n\f1option refers to the transport indicated by\f2netid\f1and hence is very site specific..SH EXAMPLEThe following example:.IP.ft 4$ rpcgen \-T prot.x.ft 1.Pgenerates the five files:\f4prot.h\f1,\f4prot_clnt.c\f1,\f4prot_svc.c\f1,\f4prot_xdr.c\f1and\f4prot_tbl.i\f1..PThe following example sends the C data-definitions (header file)to the standard output..IP.ft 4$ rpcgen \-h prot.x.ft 1.PTo send the test version of the\f4-DTEST\f1,server side stubs forall the transport belonging to the class\f4datagram_n\f1to standard output, use:.IP.ft 4$ rpcgen \-s datagram_n \-DTEST prot.x.ft 1.PTo create the server side stubs for the transport indicatedby\f2netid\f1\f4tcp\f1,use:.IP.ft 4$ rpcgen \-n tcp \-o prot_svc.c prot.x.ft 1.SH "SEE ALSO"\f4cc\fP(1).