Hi Ranchers The RMI server i developed takes 2 command line arguments: 1) port no where the registry/server will listen the request 2) location of database file (db.db) I am not asking for IP addrees of the machine where this server is installed. is it correct ? Now the problem is as i am taking the port number as parameter and create the registry at the same port using the method createRegistry() When i try to do rebind(name,obj) This method requires a url formatted name that includes the hostname and port no. But the problem is i dont have the ip address of machine where server is being tried to run? If dont give a URL formatted name then though it will bind the object in the registry located at local host but it will also take the default port which i dont want. I tried to obtain IP address using InetAddress but it does not work. Pls Help Amit
Can i use InetAddress.getLocalHost().getHostAddress() to get the ip address of the server machine.
That will get you the IP address of the local machine. The client is the one that needs the IP address of the Server. So if you get the local machines IP address you won't get the server, of course unless it is running on the same machine. Mark
Mark Actually i was talking about using this at server only while binding the connection factory in registry. Naming.rebind("rmi://"+InetAddress.getLocalHost().getHostAddress()":"+port +"/"+objConnectionFactory) i am doing so as i am taking port no as command line argument from the user while starting the server. Amit
For the server when you are binding the object, you can specify 'localhost', you don't have to use the machine name or an IP. When the client needs to make the remote connection, you will either need to specify the machine name (NOT localhost) or the IP of the server machine. IE. when I start my server, I use 'localhost' in the URL string to bind the remote object. When I start the client, I specify 192.168.1.210 as the server machine (since I use a local network).
No Eugene, yours is fine. Mine was that simple too, but there are some who want to give the user that starts things up more flexibility, even though you don't need it. But it is fine for them to have that flexibility, it is really just a preference. Mark