Rpc execution
Advertisement
This presentation is the property of its rightful owner.
1 / 7

RPC Execution PowerPoint PPT Presentation

RPC Execution. Binding Server. Register Services. Receive Query. Stub. Local Proc. Stub. Remote Proc. Local call. Query binding server. Return Server Address. Execute procedure. Unpack. Params packing. Local call. Wait. Pack results. Unpack result. Return. Return.

Download Presentation

RPC Execution

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Rpc execution

RPC Execution

Binding

Server

Register

Services

Receive

Query

Stub

Local Proc.

Stub

Remote Proc.

Local

call

Query

binding

server

Return

Server Address

Execute

procedure

Unpack

Params

packing

Local

call

Wait

Pack

results

Unpack

result

Return

Return

Caller

Callee

B. Prabhakaran


Sun rpc specification

Sun RPC Specification

Server Side:

square.x: /* file name */

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 */

Compilation Procedure:

rpcgen –C square.x /* -C: generate C prototypes in square.h */

B. Prabhakaran


Sun rpc server side

Sun RPC: Server Side

server.c:

#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);

}

Compilation Procedures:

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

Notes:

libunpipc.a: library used in Stevens book; lnsl: Solaris system library

Including RPC and XDR runtime functions

B. Prabhakaran


Client side

Client Side

client.c :

#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 <hostname> <integer_value>”);

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);

}

B. Prabhakaran


Client compilation

Client Compilation

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

Notes:

Rpcgen: generates square_xdr.c -> XDR data conversions

square_clnt.c -> client stub

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

B. Prabhakaran


Rpc client server

RPC Client-Server

RPC Specification File

square.x

rpcgen

#include

square.h

square_clnt.c

square_xdr.c

square_svc.c

server.c

client.c

Runtime

library

cc

cc

server

client

B. Prabhakaran


Rpc implementation

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.

B. Prabhakaran


  • Login