dcsimg
Client to be connected to Server on different machine, without any editing
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, August 20, 2008 09:33 AM

Hi Frnds, I am new member, recently joined. I have the code below, which has to be modified. Using RMI, a Client has to connect to Server, both on different machines. The code below works only on single machine, so my question is can anyone modify the client code to work on different machine, as dynamically getting the Client machines IPaddress/computerName and connected to server, without any entry of IPaddress/computerName manually. Server Code: public class MyServer { public static void main(String[] args) { try { MyImpl mi=new MyImpl(); java.rmi.Naming.bind("myobj", mi); } catch(Exception e) {e.printStackTra   More>>

Hi Frnds,

I am new member, recently joined. I have the code below, which has to be modified. Using RMI, a Client has to connect to Server, both on different machines. The code below works only on single machine, so my question is can anyone modify the client code to work on different machine, as dynamically getting the Client machines IPaddress/computerName and connected to server, without any entry of IPaddress/computerName manually.


Server Code:



public class MyServer {

public static void main(String[] args) {

try

{ MyImpl mi=new MyImpl();

java.rmi.Naming.bind("myobj", mi);

}

catch(Exception e)

{e.printStackTrace();

try{

Thread.sleep(10000);}

catch(Exception e1){}

}

}

}



Client Code:



public class TestClient

{

public static void main(String[] args)

{ try

{

Remote r=Naming.lookup("myobj");

MyRemote mr=(MyRemote)r;

int result=mr.add(4, 4);

System.out.println("addition "+result)
}
catch(Exception e)

{ e.printStackTrace();}

}

}



Thanks for ur help.

   <<Less
About | Sitemap | Contact