【发布时间】:2013-11-19 03:08:37
【问题描述】:
有人知道它是否可以使用本地 IP 地址恢复(主机名/机器名)吗?我知道解析反向“主机名-> ip”与DeviceNetworkInformation.ResolveHostNameAsync (endpoint, OnNameResolved, null). 完美配合
是否可以反过来做同样的事情?给定本地计算机的 IP 并检索其主机名?一千多谢
这是我的代码,但它不起作用,主机总是像 ip 一样被称为 "192.168.1.5" 。它应该返回 "computer0001"
DeviceNetworkInformation.ResolveHostNameAsync("192.168.1.5", OnNameResolved, null);
private void OnNameResolved(NameResolutionResult result)
{
IPEndPoint[] endpoints = result.IPEndPoints;
if (endpoints != null)
{
if (endpoints.Length > 0)
{
//Host always return ip adress and not the machine name
host = endpoints[0].ToString();
}
}
}
【问题讨论】:
-
你在模拟器上测试这段代码吗?
-
是的,我已经在模拟器和真正的设备(lumia 925)上试用过
标签: c# networking windows-phone-8 dns windows-phone