2021/11/02

c# netstat 예제

netstat.exe 에서 확인하던 정보를 C# 으로..  


        public void NetStat()
        {
            IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
            TcpConnectionInformation[] tcpConnInfoArray = ipProperties.GetActiveTcpConnections();

            foreach (TcpConnectionInformation tcpConnInfo in tcpConnInfoArray)
            {
                //TcpState tcpState = tcpConnInfo.State;
                //IPEndPoint localEndPoint = tcpConnInfo.LocalEndPoint;
                //IPEndPoint remotrEndPoint = tcpConnInfo.RemoteEndPoint;
            }
        }



더 세부적으로 깊게 접근하고 싶다면, Win32 라이브러리를 참조..;;

[DllImport("iphlpapi.dll",SetLastError=true)] 






댓글 없음:

댓글 쓰기

가장 많이 본 글