Vous êtes sur la page 1sur 5

Aim: Client-Server implementation of Remote Procedure Call (RPC) Theory: Rempte Procedure Call: Remote Procedure Call (RPC)

) is a protocol for requesting a service from a program located in a remote computer through network without having to understand the under layer network technologies. RPC presumes the existence of a low-level transport protocol, such as TCP or UDP, for carrying the message data between communicating programs. RPC spans the Transport layer and the Application layer in the Open Systems Interconnection (OSI) model of network communication. RPC makes it easier to develop an application that includes multiple programs distributed in a network. How it works: RPC uses the client/server model. The requesting program is a client and the serviceproviding program is the server. First, the caller process sends a call message that includes the procedure parameters to the server process. Then, the caller process waits for a reply message (blocks). Next, a process on the server side, which is dormant until the arrival of the call message, extracts the procedure parameters, computes the results, and sends a reply message. The server waits for the next call message. Finally, a process on the caller receives the reply message, extracts the results of the procedure, and the caller resumes execution.

Components of RPC Mechanism:

Fig.: Implemenation of RPC mechanism 1. Client: The client is a user process that inities a remoture procedure call. To make a remote procedure call, the cleint makes a perfectly normal local call that invokes a corresponding procedure in the client stub. 2. Client Stub: The client stub is responsible for carrying out the following two tasks: On receipt of a call request from the client, it packs a specification of the target procedure and the arguments into of a message and then asks the local RPC Runtime to send it to the server stub. On receipt of the result of procedure execution, it unpacks the result and passes it to the client. 3. RPC Runtime: The RPC Runtime handles transmission of message across the network between client and server machines. It is responsible for retransimission, acknowledgments, packet routing and encryption. The RPC Runtime on the client machine receives the call request message from the client stub and sends it to the server machine. It also receives the message from the client stub and sends it to the server machine. It also receives the

message containing the result of [rocedure execution from the server machine and passes it to the client stub. 4. Server Stub: The job of the server stub is very similar to that of the client stub. It performs the following tasks: On receipt of the call requet message from the local RPC Runtime, the server stub unpacks it and makes a perfectly normal call it to invoke the appropiate procedure in the server. On receipt of the result of procedure execution from the server, the server stub packs the result into a message and then asks the local RPC Runtime to send it to the client stub. 5. Server: On receivingf a call request from the server stub, the receiver executes the appropiate procedure and returns of procedure execution to the server stub. Advantages: Simple Call Syntax Its specification is well defined interface. Its efficiency. Procedure calls are simple enough for communication to be quite rapid.

Conclusion: Hence we have successfully implemented Remote Procedure Call using Client-Server implementation approach.

#include<iostream.h> #include<conio.h> void main() { clrscr(); int i,sp[5],cp,c,s,p; cout<<"Enter processes at server:\n"; for(i=0;i<5;i++) { cout<<"Enter: "; cin>>sp[i]; } cout<<"\nEnter RPC Prcess Number:"; cin>>cp; c=cp+12-21; cout<<"\nEncoded Name of RPC process: "<<c; cout<<"\nRequesting to Server....."; s=c+21-12; cout<<"\nDecode at Server: "<<s; p=cp+25-63; cout<<"\nServer prcocessing "<<s<<" to get result as "<<p; cout<<"\nServer send reply to client....."; p=p+69-56; cout<<"\nEncoded Result of processing: "<<s;

c=p-69+56; cout<<"\nClient decode result as: "<<c; getch(); } /* OUTPUT: Enter processes at server: Enter: 1 Enter: 2 Enter: 3 Enter: 4 Enter: 5 Enter RPC Prcess Number:4 Encoded Name of RPC process: -5 Requesting to Server..... Decode at Server: 4 Server prcocessing 4 to get result as -34 Server send reply to client..... Encoded Result of processing: 4 Client decode result as: -34 */

Vous aimerez peut-être aussi