The Remote Procedure Call packageHenry ThompsonFile:{ivy}lisp>rpc>rpc.bravo, .pressRevised:January 23, 1983 12:19 AMRemote Procedure CallsThe file rpc.dcom implements the (documentation forthcoming - ref. AndrewBirrell) Cedar RPC transport mechanism. Its architecture is copied more or less directly from theCedar implementation, to which reference should be made in difficulty. It is designed to be used inconjunction with stubs produced by the Interlisp-D version of Lupine (see below) to provide remoteservice.To start the RPC world, call InitRPC() - to turn it off, use StopRPC().LUPINE - Producing stubsThe goal of all this is to allow an Interlisp-D system to export services to or import services fromremote machines. The file lupine.dcom implements a stub creation mechanismmodeled on the Cedar version (ref. Bruce Nelson's thesis (CSL-81-9) and the Lupine User's Guide -[indigo]documentation>LupineUsersGuide.press.). In particular the functionLupine(packageName functionSpecList signalSpecList lupineTypeString) willproduce a set of server stubs to interface between the RPC transport mechanisms and a set ofvanilla Lisp functions, and a set of client stubs to communicate between callers of those functionsand the RPC transpost mechanism. This allows the network to intervene between the caller and thecallee. The crucial point to comprehend in the RPC world is that the semantics of a remote call are thesame as the semantics of a local call - all the effort is directed at hiding the fact that anything out ofthe ordinary is going on - pay no attention to the man behind the curtain.A trivial example will demonstrate the basic story - suppose we have the following Cedar interfacespec:Trivial: DEFINITIONS =BEGINTrivial: PROC[arg1: INT, arg2: Rope.ROPE] RETURNS[result: BOOLEAN];TrivialFailure: TYPE = { badNum, badString };TrivialFailed: SIGNAL[why: TrivialFailure];END.Translating this with Cedar Lupine will produce client and server interfaces to the RPC transportmechanisms. To plug into those with from Lisp, or to plug Lisp to Lisp, we must supply the sameinformation as is contained in the Cedar interface spec. to Lisp. The following records from LispLupine are used to specify an interface:(RECORD FunctionSpec (fn args result resultArg))(RECORD ArgSpec (argName argType argParm))(RECORD ResultSpec (resRecord . resBits))(RECORD ResBit (resField resType resParm))apXqipX$^r [sF* ZC VWp Srtr8 RhH P\ O`b M Jtrt G.Gp G.GuG. Gp DZrI Btr% AR"? ?R >Jt # !r <S ;A12 9a 89 5K 3+? 2J .Y -V *+t '# %C "- +  [rXa ` Sb ( t0  * ) * =Vh2The following are the equivalent for Lisp Lupine of the above interface spec:(RPAQQ TrivialSpec ((Trivial ((arg1 FIXP)(arg2 STRING)) BOOLEAN) ))(RPAQQ TrivialSignals ((TrivialFailed ENUMERATION (badNum badString) NIL) ))The same format is used for both functions and signals, since signals are just functions by anothername. Signals are described in signal.press.The types available are {SSMALLP FIXP BOOLEAN STRING ATOM STREAM ENUMERATION},where SSMALLP is -215 - 215-1, and STREAM is like string but goes directly onto a stream. Theequivalent Cedar types are {INTEGER INT BOOLEAN Rope.ROPE ATOM Rope.ROPE}. On the Lisp side, the latter two types take and additional specification -the name of the stream to use in the STREAM case, and the set of values in the ENUMERATION case.The syntax of the spec is confused by the necessity for distinguishing single from multiple returnvalues, and atomic from compound arguments to signals. Thus the result field may either have acomplex specification, giving the record name and field specifications for unpicking a multiplereturn, or it may simply give the type of a single return. In the latter case, the resultArg field isused for the parameter of the type, if any. This option of single vs. multiple is present for both theargs and result fields of a signal spec, as the function Signal itself has only one parameter for theargument(s) to the signal being raised, so if this parameter is compound it too must have a recordfor unpicking and/or constructing it. This leads to the following additional complexity, that if thesingle argument to a signal requires a parameter, then the rest of the spec. is displaced to makeroom for it. This is shown in the example above, where the single argument is an enumerated type.The NIL is the result spec. - any one of function arg, signal arg, function result, or signal result maybe NIL.If we call (Lupine 'Trivial TrivialSpec TrivialSignals "magic-string") we willget back the names of a pair of filecoms for all the necessary stubs etc. The magic-string will beused as a default in the process of matching server and client at the time of initial connection. Ifyou want to allow it to default to the same value as the default generated by Cedar Lupine, you canread it out of the file TrivialRpcClientImpl.mesa, at the point in the definition ofImportInterface where it says:type: IF ~IsNull[type]THEN type ELSE "magic-string"L,To actually export the interface so that clients can call you, you must create an instance of therecord InterfaceName, with the field instance set to the name of the service you wish toprovide, which should be a Grapevine rName. Then you can call ExportTrivial( ), where the user and password are owners of therName in the interface. Likewise to import an interface exported by someone else, useImportTrivial(). See the forthcoming Cedar RPC documentationfor a discussion of all the options with respect to establishing connections.A complete example is the easiest way to understand how all this works.{ivy}lisp>rpc>simple and ...>simpleuser are the basis for such an example.The functions in simpleuser call the functions in simple. simple contains the necessary argumentsfor Lupine. ...>simpleclient and ...>simpleserver contain the stubs generated by Lupine.simpleuser and simpleclient would be loaded into one machine, and simple and simpleserverinto another. {ivy}cedar>rpc>simple.df is a directory of all the Cedar filesneeded to make up the equivalent server and/or client in Cedar.Messages to HThompson.paNfr bM ^t2]n0 [2Zf6 W;r[ Utr R trt3r PtrQ+PQ+Ptr1 Ojtk% Mr. L%tr#t r H[ GbAvr EF DZ2"vr Bg ARvrvr vr& ?b >J X <B ;AN 9vr*7 89 5 t  t#r( M [2 trv r  Sv rvrvr! vrvrvrvr Kv rv r vrv rt#r& C?  t F >[; TIMESROMAN  TIMESROMAN  TIMESROMAN  TIMESROMANGACHA  TIMESROMAN HELVETICA  TIMESROMAN  nj/Z^- rpc.bravo hthompsonJanuary 23, 1983 1:06 AM