Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Bad Host/Port

 
joe black
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What should I do if the user enters a bad host or port?
I get an initial list of data when the GUI starts, but if there is no properties file, I show my configuration dialog first so the user can enter port and host, and then a connection is attempted using those values. What if it can't connect? Right now in my exception handler I have a message box saying no connection can be made, then I show my configration dialog again so they can enter new values, then shutdown the program. I would like to be able to have the user enter in new values and then make another attempt at connecting, and if they enter more invalid values, the process repeats until a connection is made.
[ January 02, 2004: Message edited by: Joe Black ]
 
George Marinkovich
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe,
Here's a thought:

Hope this helps,
George
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Joe,

What should I do if the user enters a bad host or port?

For my implementation, I just check whether the port number is between 1025 to 65536 inclusive.
Then, the client connects to the server to see whether can get a connection. If success, it then dispose the connection GUI, and get the data and then display the Main Window.
Otherwise, it just prompt a dialog box, saying that connection fail due to bad IP/port, without disposing the connection GUI.
In this case, I do not need to implement a while loop to wait for the result of connection.
Max has provided a good idea on how the connection works in his book. You may refer to the book to see how MVC helps in this case.
[Hint: The controller takes care all requests made to the server, including the connection. So, other components do not need to cater for this.]
Hope this help.
Nick.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic