첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System.Net;
using System.Net.NetworkInformation;

#region 포트 사용 여부 구하기 - IsPortInUse(port)

/// <summary>
/// 포트 사용 여부 구하기
/// </summary>
/// <param name="port">포트</param>
/// <returns>포트 사용 여부</returns>
public bool IsPortInUse(int port)
{
     bool inUse = false;
             
     IPGlobalProperties ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties();

     IPEndPoint[] ipEndPointArray = ipGlobalProperties.GetActiveTcpListeners();
 
     foreach(IPEndPoint ipEndPoint in ipEndPointArray)
     {
         if(ipEndPoint.Port == port)
         {
             inUse = true;

             break;
         }
     }
 
     return inUse;
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요