What is the correct way to catch the unexpected/unclean removal of an API client form a server app?
I have a server app that publishes an API.
When a client connects to the API (say using
api_Open()), certain resources are locked by the server for the exclusive use of that client.
When the client closes cleanly, it should call
api_Close() to indicate to the server that the resources are no longer required by the client and can be released for use by another client.
I need to trap the case where the client faults or otherwise exits without calling
api_Close() so that the server can release the locked resources.
How can this be done?