I have developed a java rmi program as shown below now the only thing that i want to add in it is that soon when the client send the request to server , server should capture the client details that is the client details like ip , please advise how can i add listeners so that the moment client send the request the server should capture the details ..
below is my program ..
interface :-
import java.rmi.*;
public interface AddServerInterface extends Remote {
public int sum(int a,int b);
}
implementation class :-
import java.rmi.*;
import java.rmi.server.*;
public class Adder extends UnicastRemoteObject implements AddServerInterface {
Adder()throws RemoteException{
super();
}
public int sum(int a, int b) {
return a+b;
}
}
RMI service :-
import java.rmi.*;
import java.rmi.registry.*;
public class AddServer {
public static void main(String args[]) {
try{
AddServerInterface addService=new Adder();
Naming.rebind("AddService",addService);
//addService object is hosted with name AddService.
} catch(Exception e){System.out.println(e);}
}
}
client application :-
import java.rmi.*;
public class Client {
public static void main(String args[]) {
try{
AddServerInterface st=(AddServerInterface)Naming.lookup("rmi://"+args[0]+"/AddService");
System.out.println(st.sum(25,8));
} catch(Exception e){System.out.println(e);}
}
}
please advise how can i add the functionality of passing client info the server