I am writing a Com server and I have wrote code that detect situation when COM client was closed unexpectedly, in this case I should close COM server inside COM server code.
How can I do this?
UPD: I have situations when COM server is hanged or more correctly I can’t attach to COM server from COM client, but application that contains COM server is alive, so I think that COM server can detect that all old COM clients was disconnected/closed/crashed and application will restart because no new clients attached.
I have write the following code in COM client in separate thread
while(not we are closing)
{
unknown->QueryInterface(IComServer, &server);
if (server)
return;
}
so the COM client can wait until server will really ready to work
UPD2: Just tested: after 12 minutes my COM server was closed
COM periodically pings clients to see if they are still alive and runs down interfaces from dead clients. So your server will find out eventually.