本文介绍了如果客户端关闭异常,通知Datasanap Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Delphi 2010处理HTTP DataSnap项目。



如何通知服务器客户端关闭异常(例如,杀死Proces)?



更多详细信息:
我需要我的服务器知道是否有任何客户端断开连接,这还可以,但是当任务管理器使用Kill进程关闭客户端时,会出现问题。

解决方案

您不会通知服务器客户端崩溃。通常,您不能这样做,因为您没有使用通知它—与服务器的唯一连接是客户端,并且客户端已经崩溃。



相反,您只能让服务器检测客户端不再存在。有多种方法可以做到这一点。您可以定义一个希望客户端定期发送的Keepalive信号,如果传递的消息太长而没有Keepalive消息到达,则服务器可以认为客户端已消失。另一种方法是仅检测网络操作何时失败。如果服务器尝试从套接字读取数据,但读取失败(诸如断开的管道或对等方重置连接之类的消息),则服务器会知道客户端不再存在。


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.

解决方案

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.

这篇关于如果客户端关闭异常,通知Datasanap Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 12:37