[go: up one dir, main page]

0% found this document useful (0 votes)
39 views4 pages

Remote Procedure Call

The document describes a Java RMI client-server program with three classes: RMIClient, MyInterface, and RMIServer. RMIClient acts as the client that looks up and calls methods on the remote RMIServer object. MyInterface defines the remote method signature. RMIServer implements MyInterface and provides the remote object that handles method calls from clients.

Uploaded by

SLAE slae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

Remote Procedure Call

The document describes a Java RMI client-server program with three classes: RMIClient, MyInterface, and RMIServer. RMIClient acts as the client that looks up and calls methods on the remote RMIServer object. MyInterface defines the remote method signature. RMIServer implements MyInterface and provides the remote object that handles method calls from clients.

Uploaded by

SLAE slae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Client program

import java.rmi.*;

import java.io.*;

public class RMIClient

public static void main(String args[])

try

{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

MyInterface p=( MyInterface)Naming.lookup("rmiInterface");

System.out.println("Type something...");

String input=br.readLine();

System.out.println(p.countInput(input));

catch(Exception e) {

System.out.println("Exception occurred : "+e.getMessage());

Interface program

import java.rmi.*;

public interface MyInterface extends Remote

public String countInput(String input)throws RemoteException; }


Server Program

import java.rmi.*;

import java.rmi.server.*;

public class RMIServer extends UnicastRemoteObject implements MyInterface

public RMIServer()throws RemoteException

System.out.println("Remote Server is running Now.!!");

public static void main(String arg[])

try{

RMIServer p=new RMIServer();

Naming.rebind("rmiInterface",p);

catch(Exception e)

{ System.out.println("Exception occurred : "+e.getMessage()); }

}
public String countInput(String input) throws RemoteException

System.out.println("Received your input "+ input+" at server!!");

String reply;

reply="You have typed "+ input.length() +" letters!!";

return reply;

You might also like