• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

port field

 
steve nicholls
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't include port number. The RMIRegistry by default starts on port 1099. I took the default and used that.
Mark
 
steve nicholls
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic