android sit0 ip6tnl0,GetAllNetworkInterfaces() throws exception
问题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...u
问题
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?
回答1:
Unfortunately this is a known bug in Mono for Android. The bug report is available here.
回答2:
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]
来源:https://stackoverflow.com/questions/9973980/getallnetworkinterfaces-throws-exception
更多推荐
所有评论(0)