Programmatically block all connections between process and specific host in C # / Windows
I am trying to track down some fault tolerance issues in a third party connector library we are using. I am currently starting and stopping remote services to simulate crashes, this works but is very impractical.
Is there a way that I can programmatically block all connections between a process and a given host?
EDIT: as well as blocking I would like to remove any existing connections
source to share
I think you can interact with Windows Firewall to achieve what you want (programmatically block all connections between a process and a given host), take a look at Windows Firewall Interfaces .
source to share
You can also block all connections to the host by writing an entry in the hosts file . You can just redirect the hostname to localhost or any unreachable address. But this does not apply to any process, but to the entire machine. It's easier than working with a firewall, but more global.
source to share