//IPAddress 를 숫자형으로 반환 받은 경우 문자열로 변환
public string LongToIPAddress(uint IPAddr)
{
  return new System.Net.IPAddress(IPAddr).ToString();
}

//문자열 IPAddress 를 숫자형으로 변환
public uint IPAddressToLong(string IPAddr)
{
  System.Net.IPAddress oIP=System.Net.IPAddress.Parse(IPAddr);
  byte[] byteIP=oIP.GetAddressBytes();

  uint ip=(uint)byteIP[3]<<24;
  ip+=(uint)byteIP[2]<<16;
  ip+=(uint)byteIP[1]<<8;
  ip+=(uint)byteIP[0];

  return ip;
}

//byte 단위 값을 숫자형 값으로 변환
public int LocalPort(uint dwLocalPort)
{
    return (int)(((dwLocalPort & 0xFF00) >> 8) | ((dwLocalPort & 0x00FF) << 8));
}
2010/11/06 06:10 2010/11/06 06:10

Trackback Address :: https://youngsam.net/trackback/1402