Example #1
0
        internal static string GetMyLocalIpAddress()
        {
            string localIP = "?";

#if !WINDOWS_PHONE
            IPHostEntry host;

            host = Dns.GetHostEntry(Dns.GetHostName());
            foreach (IPAddress ip in host.AddressList)
            {
                // We only want those of type InterNetwork
                if (ip.AddressFamily == AddressFamily.InterNetwork)
                {
                    // We will return the first one in the list
                    localIP = ip.ToString();
                    break;
                }
            }
#else
            FindMyIP.MyIPAddress ip = new FindMyIP.MyIPAddress();
            var addr = ip.Find();
            localIP = addr.ToString();
#endif
            return(localIP);
        }
Example #2
0
        public IPAddress[] FindAddresses()
        {
            List <IPAddress> IPs = new List <IPAddress>();

            FindMyIP.MyIPAddress finder       = new FindMyIP.MyIPAddress();
            IPAddress            localaddress = finder.Find();

            if (localaddress != null)
            {
                IPs.Add(localaddress);
            }
            else
            {
                IPs.Add(IPAddress.Parse("0.0.0.0"));
            }

            /// We get a stun address later on, so just live with the local address here

            return(IPs.ToArray());
        }
Example #3
0
		internal static string GetMyLocalIpAddress ()
		{
			string localIP = "?";
#if !WINDOWS_PHONE
			IPHostEntry host;
			
			host = Dns.GetHostEntry (Dns.GetHostName ());
			foreach (IPAddress ip in host.AddressList) {
				// We only want those of type InterNetwork
				if (ip.AddressFamily == AddressFamily.InterNetwork) {
					// We will return the first one in the list
					localIP = ip.ToString ();
					break;
				}
			}
#else            
            FindMyIP.MyIPAddress ip = new FindMyIP.MyIPAddress();
            var addr = ip.Find();
            localIP = addr.ToString();

 
#endif			
			return localIP;
		}
Example #4
0
        public IPAddress[] FindAddresses()
        {
            List<IPAddress> IPs = new List<IPAddress>();
       
            FindMyIP.MyIPAddress finder = new FindMyIP.MyIPAddress();
            IPAddress localaddress = finder.Find();
            if (localaddress != null)
                IPs.Add(localaddress);
            else
                IPs.Add(IPAddress.Parse("0.0.0.0"));

            /// We get a stun address later on, so just live with the local address here

            return IPs.ToArray();
        }