using System; using System.Collections.Generic; using System.Text; using System.Collections; using System.IO; using System.Net.Sockets; using System.Net; using System.Threading; using System.Windows.Forms; using System.Net.NetworkInformation; namespace IControls_FireManager { // TCP/IP 공통 루틴은 여기에서 구현한다 public static class _Tcp { public static string MyIP() { //return Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString(); string strIP4Address = String.Empty; foreach (IPAddress objIP in Dns.GetHostAddresses(Dns.GetHostName())) { if (objIP.AddressFamily.ToString() == "InterNetwork") { strIP4Address = objIP.ToString(); break; } } return strIP4Address; //return "192.168.0.2"; } public static string MyHostName() { return Dns.GetHostName(); } public static string MyDomain() { string result = null; IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface adapter in nics) { IPInterfaceProperties properties = adapter.GetIPProperties(); foreach (IPAddress address in properties.DnsAddresses) return result = address.ToString(); } return result; } public static string MyGateWay() { try { string result = null; NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); foreach (NetworkInterface adapter in adapters) { IPInterfaceProperties adapterProperties = adapter.GetIPProperties(); GatewayIPAddressInformationCollection addresses = adapterProperties.GatewayAddresses; if (addresses.Count > 0) { Console.WriteLine(adapter.Description); foreach (GatewayIPAddressInformation address in addresses) result = result + address.Address.ToString(); } } return result; } catch (Exception e) { // LOG _Event.DebugView_SendMessage_Write(e.ToString()); return null; } } } }