9257 DC Expt-3
9257 DC Expt-3
Experiment No. 3
y)throws RemoteException;
AdderRemote.java
Client.java import
java.rmi.registry.LocateRegistry; import
Client {
private Client() {
}
public static void main(String[] args) {
try {
// Calling the remote method using the obtained object int result =
stub.add(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
} catch (Exception e) {
e.printStackTrace();
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
public Server() {
try {
registry.bind("Hello", stub);
System.err.println("Server ready");
} catch (Exception e) {
e.printStackTrace();
Conclusion-
Postlab -
1. What are the different times at which a client can be bound to a server?
4. Session Binding: The client is bound to a specific server for the duration of
a session or interaction. Once the session ends, the binding is released. This
approach is common in stateful protocols or applications where maintaining
session state on the server is necessary.
2. How does a binding process locate a server? Mention with diagram
Service Registration:
Servers register their network address (IP address and port) and other metadata (such
as service name, version, and capabilities) with a central service registry or naming
service.
The service registry maintains a database or directory of registered services, allowing
clients to look up and locate available servers.
Client Lookup:
When a client needs to bind to a server, it queries the service registry or naming service
to locate the desired server.
The client specifies criteria such as the service name or type, version, and any other
relevant parameters to narrow down the search.
Service Discovery:
The service registry or naming service responds to the client's query by providing a list of
available servers that match the specified criteria.
Alternatively, the client may use multicast DNS (mDNS), multicast-based discovery
protocols, or other service discovery mechanisms to discover available servers
dynamically within the local network.
The client selects a server from the list of available servers based on criteria such as
load, proximity, or other application-specific requirements.
Once the server is selected, the client establishes a connection or binds to the server by
using its network address and port information obtained from the service registry or
discovery process.
Communication:
With the binding process complete, the client can now communicate with the selected
server by sending requests and receiving responses over the established connection.
3. Name some optimization methods adopted for better performance of distributed
applications using RPC and RMI.