Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sockets With Rmi

 
Vrishal Likhite
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i needed advice,
I have already combined Multicast sockets in a rmi prog but now i want to send the computer name which i have by InetAddress and receive the names all the computers on the multicast group.
can all the computers get the list of the computers on the multicast group.
This list should be ordered. i mean tat the list should have the same sequence on all the computers,

This all stuff is done in a rmi prog so its confusing me more
Should i stop using rmi and switch over to sockets only to make it easier???
Thanx
 
Tom Sullivan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure that I completely understand your question but I will try to answer it as I think it is asked.

To get values back from the server, all you need to do is to declare the method in the interface, implement the method in the Imp class and call the method in your local implementation. So in your local code, you might say:

Interface names = (Interface) Naming.lookup(address);
ArrayList<String> computerNames = names.getNames(variable);

Then you need to build a server side Interface that declares this method.

Of course, then you need to implement the method on the server side. That might look something like:

Class RMIImp {

public ArrayList<String> getNames (String variable) {

ArrayList<String> computerNames = new ComputerNameFinderClass.getNames(variable);
computerNames.sort(); //if not done in the object that returns them.
return computerNames;
}
}

Not sure that I answered your question as it would seem like you know this if you are already working with the RMI classes. I would not opt for sockets as RMI manages the connection for you and you probably don't want to build all the objects that will take care of it without RMI.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic