How can I check that the connection between the server and the client is valid at all times?
Avi Kak Because of the difficulty of differentiating between a down connection and an inactive connection, RMI does not provide an automatic check on whether a connection between a server and a client is up continuously. If a server goes down (or the server-client link breaks down) while a client is interacting with the server, the exception java.rmi.ConnectException will be thrown on the client side. The client side code can catch this exception and act as desired. But this solution obviously will not work if a client is busy doing something else when the server goes down. If you wanted a client to know at all times that a connection with the server was alive, you could define for the remote server a simple ping() like method that when invoked by the client would return something whose receipt on the client side would indicate that the server was still up. This ping() method could be invoked inside a separate thread on the client side. This thread could wake up at regular intervals and check on the server. This approach could also be used by a server to check that the client is up continuously provided the client also implements the Remote interface and is exported as a UnicastRemoteObject. As before, a ping() like method defined for such a client could be invoked by the server to ensure the connection to the client was up and running.