IP address in windows phone 8

Yes this is now possible in WP8 without using the multicast solution required for WP7. Note that you will have multiple network interfaces on your phone (e.g. three on my WP8 Emulator)

public static IPAddress Find()
{
    List<string> ipAddresses = new List<string>();

    var hostnames = NetworkInformation.GetHostNames();
    foreach (var hn in hostnames)
    {
        if (hn.IPInformation != null)
        {
            string ipAddress = hn.DisplayName;
            ipAddresses.Add(ipAddress);
        }
    }

    IPAddress address = IPAddress.Parse(ipAddresses[0]);
    return address;
}

HTH

Leave a Comment