public void IpHlpApi_CloseRemoteTcpConnectionTest()
        {
            if (!IsElevated())
            {
                Assert.Inconclusive("Must be run as administrator (or elevated) in order to perform this test");
                return;
            }

            MakeConnection("http://hotmail.com");
            var remoteIps = GetIps("hotmail.com");

            Assert.IsTrue(AddressIsFoundInTcpTable(remoteIps));
            foreach (var item in remoteIps)
            {
                IpHlpApi.CloseRemoteTcpConnection(item);
            }
            Assert.IsTrue(!AddressIsFoundInTcpTable(remoteIps));
        }
 private void TerminateAllConnectionsToSelectedItemRemoteAddress()
 {
     if (SelectedItem != null && !string.IsNullOrWhiteSpace(SelectedItem.RemoteAddress))
     {
         try
         {
             IpHlpApi.CloseRemoteTcpConnection(IPAddress.Parse(SelectedItem.RemoteAddress));
         }
         catch (Exception ex)
         {
             if (!ex.IsCritical())
             {
                 MessageBox.Show(string.Format("Exception encountered while attempting to terminate all connections to remote address '{0}':\r\n\r\n{1}", SelectedItem.RemoteAddress, ex.Message), "", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
             else
             {
                 throw;
             }
         }
     }
 }