Recently I was faced with a problem: After unit test runs, it leaves NUnit hanging on to some TCP connections. So, I needed a way to check if there were some connections left, so that I could restart application under test. I found this code bit on stackoverflow.com.
Here's the code bit:
using System.Net.NetworkInformation IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties(); TcpConnectionInformation tcpInfoList = properties.GetActiveTcpConnections();