Dns.GetHostEntry returns invalid IP addresses in Windows Mobile

This device is connected to a computer via USB using the Compact Framework:

When I call Dns.GetHostEntry ("") or Dns.GetHostEntry (IPAddress.Loopback) to get the IP addresses of the laptop, I get the IP addresses of my host computer. But when I send a packet from a PDA to my computer, they come from a different address.

Is there any way to stop this from happening? DLL call directly through P / Invoke fix?

PDA does not connect via WiFi or Bluetooth. The only connection is via USB.

+3
source share
1 answer

Dns.GetHostEntry(""), , IPHostEntry.AddressList 127.0.0.1 (, , , ). Dns.GetHostEntry(IPAddress.Loopback) : 127.0.0.1 :: 1.

IP- -, IP- . IP- , - :

IPHostEntry hostent = Dns.GetHostEntry(Dns.GetHostName());

foreach (var addr in hostent.AddressList)
{
    Debug.WriteLine(addr.ToString());
}
+2

Source: https://habr.com/ru/post/1713760/


All Articles