aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes port field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "port field" Watch "port field" New topic
Author

port field

steve nicholls
Greenhorn

Joined: Dec 10, 2002
Posts: 20
I am not using the port number parameter, we can request from the user. When I start the server, I use Naming.rebind("serverName", Object) and when the client connects to the server, it uses:
Naming.lookup("rmi://ipAddress/serverName");
Where ipAddress is the IP address without a port number. So is the port field necessary? Does the RMI client seek out the first available RMI server at that IP address with that name? Can errors occur if the port number is not specified?
Thanks,
Steve
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I didn't include port number. The RMIRegistry by default starts on port 1099. I took the default and used that.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
steve nicholls
Greenhorn

Joined: Dec 10, 2002
Posts: 20
Thanks Mark.
FYI: I did a little research into this area. As you stated, the RMI server will default to port 1099 if the default UnicastRemoteObject constructor is used. Likewise, serveral RMI servers can be loaded onto one port, with the server name being the unique identifier. Consequently, when using rebind(String, Object) to specify the server name (String), the method will fail if the name already exists. If no port is specified on the client side (in the rmi url), the lookup(String) method will search on port on the default port. So it would appear for this program, a port does not need to be specified, but the server should ensure the Server name is unique before trying to rebind.
Also, as a side note, the default RMI port can be switched by specifying this in the command line, for example:
$ rmiregistry 10123
will use port 10123 as the default port. I hope this research is useful to anyone else with port questions.
 
wood burning stoves
 
subject: port field