.NET Remoting客户端已断开连接 [英] .NET Remoting client disconnected

查看:402
本文介绍了.NET Remoting客户端已断开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有.NET Remoting服务器和客户端应用程序,它基于从服务器引发的事件来向客户端发送数据.....当某些客户端由于LAN连接或其他原因而断开连接时,它如何服务器应用程序可以从其调用列表中删除已注册的事件.

I have .NET Remoting server and client application based on events raising from server to send data to clients.......... when some client disconnected due to LAN connection or due to some other reason, how it is possible to for server application to remove registered event from its invocation list.

推荐答案

检查此代码项目链接
如何使用.NET Remoting停止服务 [
check this codeproject link
How to stop a service using .NET Remoting[^]
--NDK


这个问题可以很好地解决,但是整个问题看起来都不一样,因为我建议的设计不是基于事件的.基本上,您使应用程序成为多线程.该服务需要两个线程;一种用于侦听新连接,一种用于从网络流读取/写入网络流.这个想法是使用异常驱动的断开连接句柄,它排除了正常断开连接的需要(无论如何也无法保证,因为断开连接也是偶然的).异常处理程序查看代表远程客户端套接字的句柄,并将其从包含此类有问题的客户端套接字的容器中删除.

有关更多详细信息,请参阅我过去针对此问题的解决方案:
使用api在c#和socketprogramming中 [ ^ ].

—SA
This problem is solved very elegantly, but the whole problem looks different, because the design I would advise is not based on events. Basically, you make applications multi-threading; and the service needs two threads; one for listening for new connections, one reading/writing from/to a network stream. The idea is to use exception-driven handle of disconnections, which excludes the need in graceful disconnections (which is impossible to guarantee anyway, because disconnection can be also accidental). The exception handler looks at the handle representing the remote client sockets and removes it from the container holding such offending client socket.

For some more detail, please see my past solution for this problem: using api in c# and socketprogramming[^].

—SA


这篇关于.NET Remoting客户端已断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆