Exp - 1 (DC)
Exp - 1 (DC)
THEORY:
RPC is a powerful technique for constructing distributed, client-server-based applications. It is based on
extending the notion of conventional, or local procedure calling, so that the called procedure need not
exist in the same address space as the calling procedure. The two processes may be on the same system,
or they may be on different systems with a network connecting them. By using RPC, programmers of
distributed applications avoid the details of the interface with the network. The transport independence
of RPC isolates the application from the physical and logical elements of the data communications
mechanism and allows the application to use a variety of transports.
RPC makes the client/server model of computing more powerful and easier to program. When combined
with the ONC RPCGEN protocol compiler clients transparently make remote calls through a local
procedure interface.
An RPC is analogous to a function call. Like a function call, when an RPC is made, the calling arguments are
passed to the remote procedure and the caller waits for a response to be returned from the remote
procedure. Figure shows the flow of activity that takes place during an RPC call between two networked
systems. The client makes a procedure call that sends a request to the server and waits. The thread is
blocked from processing until either a reply is received, or it times out. When the request arrives, the
server calls a dispatch routine that performs the requested service, and sends the reply to the client. After
the RPC call is completed, the client program continues. RPC specifically supports network applications.
Program Code:
import
java.io.*;
import
java.net.*;
class ser {
import
java.io.*;
import
java.net.*;
class cli {
keyRead.readL
ine();
pwrite.println(
sendMessage);
System.out.flus
h();
if ((receiveMessage =
receiveRead.readLine()) != null)
{ System.out.println(receiveMess
age);
}
}
}
}
Output:
Operation :
a
d
d
P
a
r
a
m
e
t
e
r
1
: 84
Parameter 2 : 6
Addition = 90
Conclusion:
Hence, we have studied and run Client-Server based RPC program successfully