2012年10月15日 星期一

c# create a netstat clone

Reference
1. reference
 using System.Net.NetworkInformation;
2. add code
  IPGlobalProperties properties = IPGlobalProperties.GetIPGlobalProperties();
//            TcpConnectionInformation connections = properties.GetActiveTcpConnections();
            TcpConnectionInformation[] connections = properties.GetActiveTcpConnections();

            foreach (TcpConnectionInformation t in connections)
            {
                Console.Write("Local endpoint: {0} ",t.LocalEndPoint.Address);
                Console.Write("Remote endpoint: {0} ",t.RemoteEndPoint.Address);
                Console.WriteLine("{0}",t.State);
            }
            Console.WriteLine();

沒有留言: