Subject Broken connection

I made out-of-process server which keeps database connections alive
all the time. But the prolem is that during the night interbase
server is shut down couple times a week for few hours.

This causes connection error on Com server. I've tried catch
an error in TIB_Database OnError event to close connection
to interbase.

So, What is the best way close connections and ping the server
to reconnect properly to database.

Mikko Nieminen