• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to check if the website is alive or not

 
Neo Chung
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone, I got a problem to see if the website is alive or not .I read the Java API about the net package but I can not find a suited method or object to solve the problem.
thanks in advanced
Neo
 
Van Glass
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally you would do this using the PING command. Unfortunately Java does not support the ICMP protocol (the protocol needed to support PING).
The other option is to try and open a socket connection to port 80 on the web server. Unfortunately in cases where the server is down Java will block I/O for up to several minutes before throwing an exception.
To solve this problem you will probably want to open a connection to port 80 and throw an exception if the connection cannot be established within a certain period of time (e.g. 5 seconds).
Take a look at the com.jscape.inet.util.TimedSocket class in iNet Factory available for download at http://www.jscape.com
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!