Notifying the Datasanap Server if the a client closed abnormal

浪子不回头ぞ 提交于 2020-01-15 05:33:07

问题


I am working on HTTP DataSnap project using Delphi 2010.

How to Notify the server that an client is closed abnormal (Killing Proces for ex.)?

more detail: I need my server to know if any client is disconnected, Its OK but the problem is raised when the client is closed by task manager using Kill process.


回答1:


You don't notify the server that the client crashed. You generally can't because you have nothing to notify it with — your only connection to the server was the client, and the client has already crashed.

Instead, you can merely have the server detect that the client is no longer present. There are multiple ways to do that. You could define a keepalive signal that the client is expected to send periodically, and if too long passes without a keepalive message arriving, the server can assume the client is gone. Another method is to just detect when network operations fail. If the server tries to read from the socket, and the read fails (with something like "broken pipe" or "connection reset by peer") then the server knows the client isn't there anymore.



来源:https://stackoverflow.com/questions/12196141/notifying-the-datasanap-server-if-the-a-client-closed-abnormal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!