[C#] netstat in c#
using System;
using System.Net;
using System.Net.NetworkInformation;
namespace MyNetstat
{
class Program
{
static void Main(string[] args)
{
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] endPoints = ipProperties.GetActiveTcpListeners();
TcpConnectionInformation[] tcpConnections = ipProperties.GetActiveTcpConnections();
foreach (TcpConnectionInformation info in tcpConnections)
{
Console.WriteLine("Local : " + info.LocalEndPoint.Address.ToString()
+ ":" + info.LocalEndPoint.Port.ToString()
+ "\nRemote : " + info.RemoteEndPoint.Address.ToString()
+ ":" + info.RemoteEndPoint.Port.ToString()
+ "\nState : " + info.State.ToString() + "\n\n");
}
Console.ReadLine();
}
}
}
'Dev by INNO > C#' 카테고리의 다른 글
CLR String TitleCase Function in SQL Server 2005 (CLR Integration) (0) | 2010.05.12 |
---|---|
[C#]NETSTAT 구하기 (0) | 2010.05.10 |
[C#] textbox 에서 ctrl + a 했을때 전체선택 (0) | 2010.02.11 |