Server detects crashed COM clients for clean shutdown... How?
Posted on 2001-09-04
I am working on a project that involves COM/DCOM client/server type coding. I am not the most experienced COM developer, so please excuse me if this is a dumb question!
My problem is this:
I have a client (console) which makes a connection to a server (.exe service module). The server starts running and everything is fine. Another console starts running, incrementing the servers reference count. Now one console crashes, and I mean total unclean crash, when the other console shuts down, the server remains running. It still has a reference count from the crashed client, but this will never be released.
I am looking for some way of finding out, from inside the server, that the client is no longer available. For example, when a reference is released, the server checks to ensure there is at least 1 client still actively connected, i.e. it is still running. If there is no-one but reference counts remain, it assumes some clients have crashed and it self-destructs.
Our servers all have pump threads in them, and the only possibilty I have right now is to have an event interface with a Test() method in it. All clients implement this interface, and simply respond to the Test() event with a "return S_OK". Periodically the server fires the Test() event to all connections, if it does not receive a S_OK return it concludes the client is gone.
However, I am looking for a cleaner solution, preferably without requiring any special coding or participation from the client.
Does anybody out there have any smart ideas?
Many thankx in advance,