예제 #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
        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);
        }
예제 #3
0
        public static bool IsLoopback(IPAddress address)
        {
            __IPAddress a = address;

            if (a.InternalAddress.isLoopbackAddress())
            {
                return(true);
            }


            // oldschool
            return(a.ToString() == "127.0.0.1");
        }
예제 #4
0
        public static IPAddress Parse(string ipString)
        {
            // Z:\jsc.svn\examples\java\hybrid\ubuntu\UbuntuTCPMultiplex\Program.cs

            var sw = Stopwatch.StartNew();
            var a = new AutoResetEvent(false);

            var value = new __IPAddress { };


            new Thread(
               delegate()
               {
                   //Console.WriteLine("enter __IPAddress Parse");

                   a.Set();

                   try
                   {
                       value.InternalAddress = global::java.net.InetAddress.getByName(ipString);

                       // http://msdn.microsoft.com/en-us/library/system.net.ipaddress.any.aspx
                   }
                   catch (Exception ex)
                   {
                       Console.WriteLine(new { ex.Message, ex.StackTrace });

                       //throw;
                   }
                   //Console.WriteLine("exit __IPAddress Parse " + new { sw.ElapsedMilliseconds });

               }
           ).Start();

            a.WaitOne();
            Thread.Sleep(1);

            return value;

        }
예제 #5
0
        public static IPAddress Parse(string ipString)
        {
            // Z:\jsc.svn\examples\java\hybrid\ubuntu\UbuntuTCPMultiplex\Program.cs

            var sw = Stopwatch.StartNew();
            var a  = new AutoResetEvent(false);

            var value = new __IPAddress {
            };


            new Thread(
                delegate()
            {
                //Console.WriteLine("enter __IPAddress Parse");

                a.Set();

                try
                {
                    value.InternalAddress = global::java.net.InetAddress.getByName(ipString);

                    // http://msdn.microsoft.com/en-us/library/system.net.ipaddress.any.aspx
                }
                catch (Exception ex)
                {
                    Console.WriteLine(new { ex.Message, ex.StackTrace });

                    //throw;
                }
                //Console.WriteLine("exit __IPAddress Parse " + new { sw.ElapsedMilliseconds });
            }
                ).Start();

            a.WaitOne();
            Thread.Sleep(1);

            return(value);
        }
예제 #6
0
        public static bool IsLoopback(IPAddress address)
        {
            __IPAddress a = address;

            return(a.InternalAddress.isLoopbackAddress());
        }