TCP 服务器断开连接/电缆已拔出 [英] TCP Server disconnect/cable unplugged

查看:34
本文介绍了TCP 服务器断开连接/电缆已拔出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含一台服务器和一台客户端的应用程序.客户端如何知道服务器电缆是否已拔下或断开连接?有活动吗?我不想设置一个计时器来偶尔检查服务器是否收到消息......而且我不想使用投票...

I have an application with one server and one client. How the client will know if the server cable is unplugged or disconnect? Is there event for that? I don’t want to set a timer to check occasionally if the server gets messages… And i don't want to use poll...

谢谢,艾拉德

推荐答案

参考那个问题:

StackOverflow 2

Yopu 必须分析所有阶段的连接状态,并了解在哪个阶段出现问题,无论如何无法连接.

Yopu have to analyze the connection status in all the phases and understand in wich phase are the problem, anyway why the connection doesn't works.

还有其他链接指向您的问题:

There are also other link that refer to your question :

最后一种方法,使用 NetworkChange.NetworkAvailabilityChanged 事件

Last method, work with NetworkChange.NetworkAvailabilityChanged Event

链接:在此处输入链接描述

这篇关于TCP 服务器断开连接/电缆已拔出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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