• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Do we need host,port,and db name when we use RMI ?

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
According to my understanding,a server object registers itself with rmiregistry using a name. The client lookups the server object using the same name. This is what I found from several books and articles.Under this understanding:
1) What's the purpose for us to provide the host DNS, and port as command line arguments ?
Besides of using them to distinguish the local and remote mode, I can not see they are needed for remote communication or remote data access.
I know that they are absolutely necessary for Socket. But,I can not see the purpose for us to have them in RMI implementation. Please explain to me how we can use them for remote communication in RMI.
2) In which machine should we start the rmiregistry ? If the rmiregistry is started in server machine,how can client find the rmiregistry ? Vice or Versa for server ?
Thanks,
John Chien
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey man,
As for "1)":
First of all, i hope when you say "provide the host DNS and port " you are referring to the client. So that's that.
Here is an example command line used to access remote objects from some client:
DataServer dataServer = (DataServer) Naming.lookup("rmi://" + arg[0] + ":" + arg[1] + "/DataServer"); where arg[0] stands for host (as an IP number or DNS name) and arg[1] for port (as an ordinary integer)
Clearly, you need to know the IP address and the port number. (actually you can skip the port numeber as in rmi://somehost/DataServer. in this case the client will try to connect to the server on the standard RMI port which is 1099)
as for "2)":
rmiregistry is started on the server machine:
>rmiregistry 3456
for example.
If skip port, the default port will be used and the client will have to try to connect to this default port (1099) to successfully locate the remote object DataServer.
So the client on the othere side of the connection tried to connect to the specified host name and port. this is why you need these two parameters.
hope i helped you a bit.
 
John Chien
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lev:
Thank you for the response.
I re-look at the RMI book that I consulted.
I think you are right.
In the book, the client does the lookup using the host: rmi://host/dataserver and the server register using rmi://dataserver. Originally, I thought that is a typo. Now, I know that it is needed.
Thanks,
John Chien
reply
    Bookmark Topic Watch Topic
  • New Topic