[MonoTouch] Can't determine IP address on iPhone device
jowi
j.wiersma17 at chello.nl
Mon Oct 10 15:00:32 EDT 2011
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.
///first is to get the hostname/
string host = Dns.GetHostName();
///then i check if i'm on a device or a sim, if on a device, i add the
.local to the name/
if( IsDevice ) host = host + ".local";
///get the list of ip adresses for this host/
IPAddress[] localIPs = Dns.GetHostAddresses(host);
On the iphone device, the array only contains a short hex address and the
127.0.0.1 address.
On the ipad device, this also contains the actual ip address.
Again, on the simulator this works perfectly.
Environment: Xcode 4.1, MD 2,8, MT 4.2.2
iPhone: iOS 4.2.1
--
View this message in context: http://monotouch.2284126.n4.nabble.com/Can-t-determine-IP-address-on-iPhone-device-tp3891425p3891425.html
Sent from the MonoTouch mailing list archive at Nabble.com.
More information about the MonoTouch
mailing list