Ejemplo n.º 1
0
        public static IPHostEntry GetHostByName(string hostName)
        {
            if (hostName == null)
            {
                throw new ArgumentNullException("hostName");
            }
            string h_name;

            string[] h_aliases;
            string[] h_addrlist;
            if (!Dns.GetHostByName_internal(hostName, out h_name, out h_aliases, out h_addrlist))
            {
                throw new System.Net.Sockets.SocketException(11001);
            }
            return(Dns.hostent_to_IPHostEntry(h_name, h_aliases, h_addrlist));
        }
Ejemplo n.º 2
0
        private static IPHostEntry GetHostByAddressFromString(string address, bool parse)
        {
            if (address.Equals("0.0.0.0"))
            {
                address = "127.0.0.1";
                parse   = false;
            }
            if (parse)
            {
                IPAddress.Parse(address);
            }
            string h_name;

            string[] h_aliases;
            string[] h_addrlist;
            if (!Dns.GetHostByAddr_internal(address, out h_name, out h_aliases, out h_addrlist))
            {
                throw new System.Net.Sockets.SocketException(11001);
            }
            return(Dns.hostent_to_IPHostEntry(h_name, h_aliases, h_addrlist));
        }