Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Choosing server port

 
David Abramowicz
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question...

Is allowing the user to choose server port a MUST??? I don't think it is, I just want to make sure.

I was thinking of allowing the manual setting of port in the Server GUI, but after reading previous posts it seems impossible to change registry to a different port without restarting the JVM.

This has led me to conclude that it would be pretty ugly to include the choice unless I have to...

Any thoughts or opinions would be appreciated.

Cheers /Dave
 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I definitely think you should allow the User to choose the port when starting the server. It's not guaranteed that every User will have the default port that you choose open, therefore you should let them decide what port to run the server on. And because of that, you're going to have to allow the Client to choose the server port to connect to as well.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a real world application, I would definately allow the port to be configurable. However, for the purpose of this assignment, I don't think it is neccessary. If you want to do it, go ahead. If you want to leave it out for simplicity's sake, that is fine too.

FYI, I am pretty sure you are correct David, you cannot change the registry to a different port without restarting the JVM.
 
dennis du
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
----------------------
FYI, I am pretty sure you are correct David, you cannot change the registry to a different port without restarting the JVM.
-----------------------------------------
What do you mean? restarting the JVM?? How come?
You only should do is : restart your application ,choose a new port.

or you should >rmiregistry new_port
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean? restarting the JVM?? How come?
You only should do is : restart your application ,choose a new port.
Yes, that is what I was referring to. For more info, check out
this thread.
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Bourdeaux:
Yes, that is what I was referring to. For more info, check out
this thread.


Since I wrote that reply in that thread I've changed my server to have a GUI and allow changing the port. What I do is let the user specify a new port , but inform her that she will need to restart the server for that change to be effective. This behaviour is common for Windows configuration changes and should be no surprise to a network admin, it's also infrequent. After even more research, including hacking some low level stuff, I can confirm that that ObjID prevents you from closing a registry that you have opened in your application and starting another one.

If you really want to do this you can use Runtime.exec("rmiregistry") and fight all those problems with platform dependencies and controlling a seperate process.

Or you can take the easy way out and just use port 1099, be sure to explain why you chose this one.
[ January 28, 2005: Message edited by: peter wooster ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic