示例#1
0
        public static IPHostEntry GetHostEntry(string hostNameOrAddress)
        {
            var a = default(InetAddress[]);

            try
            {
                a = InetAddress.getAllByName(hostNameOrAddress);
            }
            catch
            {
                throw new InvalidOperationException();
            }

            var z = new __IPAddress[a.Length];

            for (int j = 0; j < a.Length; j++)
            {
                z[j] = new __IPAddress {
                    InternalAddress = a[j]
                };
            }

            var i = new __IPHostEntry();

            i.AddressList = (IPAddress[])(object)z;

            return((IPHostEntry)(object)i);
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public java.net.InetAddress[] resolveDomainName(String hostname) throws UnknownHostException
        public override InetAddress[] ResolveDomainName(string hostname)
        {
            try
            {
                return(InetAddress.getAllByName(hostname));
            }
            catch (java.net.UnknownHostException e)
            {
                throw new UnknownHostException(e);
            }
        }