Search code examples
c#tcp

Close an external TCP connection


How can I terminate a TCP connection which is not handled by my program?

for example I want to close all the connection on port 10202 and I don't want them to reopen, but I want to allow the other ports. everything in C#.

like Sysinternals' tcpView does


Solution

  • You'd have to p/Invoke SetTcpEntry. TCPView uses Dark and Mysterious Methods to do the same even on platforms that don't support that function.