简体   繁体   中英

How to simulate tcp connection loss on localhost

I have a ASP NET Core web api that uses websockets. I am trying to find out if the server handles internet connection loss (client side) correctly.

However since I have only one machine on which both the server and the client run, i know that localhost does not use the Network Interface, and the desired handler is not triggered when I cut off the internet.

How can I thus have a server that runs a localhost, and a client that also runs on localhost but uses the network interface, so that I can cut the internet off and see how the server behaves for the given client?

I useTCPView to do this sort of testing. You can find the connection in the list, then right-click/close it:

在此处输入图像描述

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