user302823
user302823

Reputation: 361

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

Upvotes: 2

Views: 1485

Answers (2)

Stephen Cleary
Stephen Cleary

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

bramp
bramp

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

Related Questions