Download presentation
Presentation is loading. Please wait.
Published byBernard Waters Modified over 9 years ago
1
B. Prabhakaran 1 RPC Execution Local call Return Query binding server Params packing Wait Unpack result Unpack Local call Pack results Execute procedure Return Receive Query Return Server Address Register Services Binding Server Caller Callee Stub Local Proc. Remote Proc.
2
B. Prabhakaran 2 Sun RPC Specification struct square_in { /* input argument */ long arg1; } struct square_out { /* output argument */ long res2; } program SQUARE_PROG { version SQUARE_VERS { square_out SQUAREPROC(square_in) = 1; /* procedure no. = 1 */ } = 1; /* version number */ } = 0x3123 0000; /* program number */ Server Side: square.x: /* file name */ rpcgen –C square.x /* -C: generate C prototypes in square.h */ Compilation Procedure:
3
B. Prabhakaran 3 Sun RPC: Server Side #include “unpipc.h” /* local headers */ #include “square.h” /* generated by RPCgen */ square_out * squareproc_1_svc (square_in *inp, struct svc_reg *rqstp) { static square_out out; out.res1 = inp->arg1 * inp->arg1; return(&out); } server.c: cc –c server.c –o server.o cc –c square_svc.c –o square_svc.o /* contains “main” */ cc –o server server.o square_svc.o square.xdr.o libunpipc.a -lnsl Compilation Procedures: Notes: libunpipc.a: library used in Stevens book; lnsl: Solaris system library Including RPC and XDR runtime functions
4
B. Prabhakaran 4 Client Side #include “unpipc.h” /* local headers */ #include “square.h” /* generated by rpcgen */ main(int argc, char **argv) { CLIENT *cl; /* defined in rpc.h */ square_in in; square_out *outp; if (argc != 3) err_quit(“usage: client ”); cl = Clnt_create(argv[1], SQUARE_PROG, SQUARE_VERS, “tcp”); in.arg1 = atol(argv[2]); if ((outp = squareproc_1(&in, cl) == NULL) err_quit(“%s”, clnt_sperror(cl, argv[1])); printf(“result: %d\n”, outp->res1); exit(0); } client.c :
5
B. Prabhakaran 5 Client Compilation cc –c client.c –o client.o cc –c square_clnt.c –o square_clnt.o cc –c square_xdr.c –o square_xdr.o cc –o client client.o square_client.o square_xdr.o libunpipc.a -lnsl Compilation: Execution: client bsdi 11 -> result: 121 client 209.76.87.90 22 -> result: 484 client nosuchhost 11 -> nosuchhost:RPC:Unknownhost…. Client localhost 11 -> localhost: RPC: Program not registered Notes: Rpcgen: generates square_xdr.c -> XDR data conversions square_clnt.c -> client stub
6
B. Prabhakaran 6 RPC Client-Server square.x RPC Specification File square.h client.c square_clnt.c square_xdr.c square_svc.cserver.c cc client server rpcgen Runtime library #include
7
B. Prabhakaran 7 RPC Implementation Sending/receiving parameters: Use reliable communication? : Use datagrams/unreliable? Implies the choice of semantics: how many times a RPC may be invoked. Reference Book: Unix Network Programming by Richard Stevens, Prentice-Hall.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.