Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Get connection status  RSS feed

 
Reza Mochamad Diannagara
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i've build an application to control an application server remotely. i need to add a function that catch the connection status to the app server. i.e, my app connected to application server, then somehow the application server was shutdown. how to know the if the application server was shutdown, from my app? i use Socket to connect to the application server.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "Reza MD"-

You've been around the ranch long enough to know that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to your question, one way would be to send a kind of "ping" every so often (maybe every few seconds). That could be a one-byte message to which an equally short answer is sent with a status code that indicates conditions like "UP", "ABOUT TO GO DOWN", and whatever other conditions are appropriate in your situation. Getting an exception when trying to do this would also indicate a problem.
[ June 13, 2008: Message edited by: Ulf Dittmer ]
 
Reza Mochamad Diannagara
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

thank for remind me about the screen name. actually it's my true name, i just make it short. coz' in real life, that is well known for people who know me.

btw, can i pinging a port? because, the application server that i mean is an application act as a server and my app connect to it using socket to a certain port. so it is a client server application.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you're writing the application, just provide a second port exclusively for "pinging". Connections to that port should be understood as status connections; the server should respond with "OK" or whatever makes sense.
 
Reza Mochamad Diannagara
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hm...

i just wrote client app.
 
Stony Zhang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Ulf Dittmer. That's a good solution.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!