如何在客户端和服务器之间模拟套接字断开连接(在窗口上)? [英] How can I simulate a socket disconnection (on windows) between a client and a server?

查看:304
本文介绍了如何在客户端和服务器之间模拟套接字断开连接(在窗口上)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一种心跳解决方案,我希望看到在实际情况下网络发生故障时会发生什么,特别是当插座上没有流量时发生这种情况。

I've implemented a kind of 'heartbeat solution' and I'd like to see what happen when the network 'goes down', in real conditions, specially if it happens when there is no traffic on the socket.

问题:
- 我只有一台电脑;
- 我在windows / java上;

Problems: - I've got only one computer; - I'm on windows/java;

我想只需拔掉网线/停用网卡就不会影响这两个进程,如他们在同一个盒子里跑;是否有程序化解决方案?一种强制关闭套接字的方法?

I guess that simply unplugging the network cable/deactivating the network card won't affect the two processes, as they are running on the same box; Is there a programmatic solution to that? A kind of way to force close a socket ?

推荐答案

我使用 TCPView 右键单击并关闭套接字。

I use TCPView to right click and close sockets.

这篇关于如何在客户端和服务器之间模拟套接字断开连接(在窗口上)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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