简体   繁体   中英

How can I simulate a socket disconnection (on windows) between a client and a server?

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.

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右键单击并关闭套接字。

如果您正在使用Eclipse,则有一个TCP / IP监视器,WIndow - > Show View - > Other - > type filter text = TCP / IP并创建一个新的转发tcp / ip,您可以监视并在中间停止它。

You can also simulate two computers with virtual computers.

I use VirtualBox for making myself more computers :D.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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