[MonoTouch] Can't determine IP address on iPhone device

Miguel de Icaza miguel at xamarin.com
Fri Oct 14 20:55:16 EDT 2011


Hello,

Another day, another question :) i've been using the (simplified) code below
> to determine the ip address of the device (or simulator). This works
> perfectly on the ipad/iphone simulator, and also on the real ipad device,
> but not on the iphone.
>

You can try this code instead:

foreach (var iff in NetworkInterface.GetAllNetworkInterfaces ()){
Console.WriteLine (iff.ToString());
foreach (var a in iff.GetIPProperties ().UnicastAddresses)
Console.WriteLine (a.Address);

That uses the device APIs to fetch the list of interfaces and the IP
addresses associated with each interface.

Miguel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20111014/725102f2/attachment.html 


More information about the MonoTouch mailing list