简体   繁体   English

检测Windows上服务器端的RPC连接丢失

[英]Detect RPC connection loss from server-side on Windows

Is there any way to check the status of the RPC connection from the server-side? 有没有办法从服务器端检查RPC连接的状态? I am looking for a way to detect if the connection from the client is lost, be it client crash or other connectivity issues. 我正在寻找一种方法来检测客户端连接是否丢失,无论是客户端崩溃还是其他连接问题。

Use Context Handles for managing server state between calls for a particular client. 使用Context Handles管理特定客户端的调用之间的服务器状态。 RPC uses keep-alive's to detect client disconnects and will execute your context handle rundown routine if the client disconnects. RPC使用keep-alive来检测客户端断开连接,并在客户端断开连接时执行上下文句柄断开例程。

Mo Flanagan's answer is the best IMHO. Mo Flanagan的答案是最好的恕我直言。 Some more context. 更多背景。

If you're using binding handles, there is no way of tracking state across RPC calls and the concept of a "client disconnect" is essentially meaningless - you still need to return from the RPC call. 如果您正在使用绑定句柄,则无法跨RPC调用跟踪状态,并且“客户端断开连接”的概念基本上没有意义 - 您仍然需要从RPC调用返回。

If you're using context handles, then the RPC runtime library will call the _rundown function when the client disconnects. 如果您正在使用上下文句柄,那么RPC运行时库将在客户端断开连接时调用_rundown函数。

When that routine is called, the server can clean up whatever it needs to. 调用该例程时,服务器可以清理它需要的任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM