Reputation: 115
In Mono for Android I'm trying to obtain all the IP addresses for my device within the local network.
I don't mind loopbacks but I'm not interested in calling DNS.
The best way seems to be calling...
using System.Net.NetworkInformation;
NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
...except it throws...
System.EntryPointNotFoundException: getifaddrs
Any suggestions?
Upvotes: 4
Views: 2606
Reputation: 1
If you only use Mono for Android, you can try this code to obtain every IP:
Java.Util.IEnumeration networkInterfaces = NetworkInterface.NetworkInterfaces;
while(networkInterfaces.HasMoreElements) {
Java.Net.NetworkInterface netInterface = (Java.Net.NetworkInterface)networkInterfaces.NextElement();
Console.WriteLine(netInterface.ToString());
}
Output:
[lo][1][/::1%1%1][/127.0.0.1]
[dummy0][2]
[sit0][3]
[ip6tnl0][4]
[wlan0][5][/fe80::8e77:12ff:fe5a:6052%wlan0%5][/192.168.100.135]
[ppp0][6][/10.0.0.1]
Upvotes: 0
Reputation: 10139
Unfortunately this is a known bug in Mono for Android. The bug report is available here.
Upvotes: 6