Reputation: 361
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
Upvotes: 2
Views: 1485
Reputation: 457217
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.
Upvotes: 4
Reputation: 9741
I don't know how TCPView does it, but you could generate a TCP Fin packet and fire it at yourself.
I don't know how to do that in C#, but you might be able to find a way.
Upvotes: 2