• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

check if server is online

 
Paul Sun
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi:
I do the assignment with socket. I meet a problem that how to check if server is online?
In this application, if server shutdown and restart again, client should re-connect it again.
Thanks.
regards.
Paul
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

In this application, if server shutdown and restart again, client should re-connect it again.

In my design, if the server shut down, I just popped up a dialog to notify the user and disabled everything but exit and the help files. In order to reconnect, the user had to start a new client.
When you say shutdown, do you mean exit the application? If so and you still want to notify clients when the server comes back up, you have to have some sort of persistence scheme to hold connected clients. It could be a simple property file that you log clients to whenever they connect and remove when they disconnect. You could even use Data itself to create a client log database. Either way, whenever the server comes up, it would read the property file or database and send a message to all previously connected clients that the server was now up.
Hope this helps,
Michael Morris
[ September 08, 2002: Message edited by: Michael Morris ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic