I was wondering if it’s possible to use .NET to disable a certain network interface or, in alternative, to drop all the existing TCP connections (from the whole system) and then inhibit further creation.
I’m asking this because I want to write a small C# utility that monitors the system and blocks networking (or at least TCP connections) for a certain amount of time if the overall speed drops below a threshold.
And then I’d want it to restore connectivity after a certain number of minutes.
From what I understand monitoring a NIC throughput from within .NET is fairly easy.
But I don’t know if it’s possible to block a whole NIC or TCP connections.
Maybe with P/Invoke and WMI?
I found this: How to kill any network connection. There is an entire class written by a guy to kill any network connection. It revolves around these two imports in your code from the IP Helper (MSDN Link) API:
Have a look, it should either solve your problem or at least point you in the right direction.