How can I poll a remote server, to see if it is still available? I'd like to check to see if the server has crashed, and if so, record the time.


If your application is a TCP server, the easiest way to do this is for a client to connect to it, using the class. When the Socket is connected, if the server is down an  IOException will be thrown, indicating that the server is not accepting connections.

However, this may not be a sufficient test for mission critical applications. What if the server has stalled, and will accept connections but not respond to them? In this situation, you'll need to write a valid request to the server (using the appropriate network protocol, such as HTTP or FTP). It doesn't matter what type of request is made, or what data is really returned (unless it is an error message). The only purpose of the request is to see if the server will response, and is still available for use.