如何以编程方式刷新 Windows Mobile 中的 DNS 缓存?

发布于 2024-08-27 12:55:50 字数 615 浏览 2 评论 0原文

我的 Windows Mobile 应用程序(使用紧凑框架用 C# 编写)需要知道特定机器是否处于活动状态。

为了达到这个目的,我想到了使用ping机制。我尝试使用 opennetcf 框架中实现的 Ping 类(.NET Framework 的 System.Net.NetworkInformation.Ping 类不是紧凑框架的一部分)。

因为我为 Ping.Send 函数提供了一个主机名,所以它首先尝试解析该主机名并检索 IP 地址。

但我观察到以下问题: 如果第一个 dns 解析失败(因为此时网络已关闭),并且应用程序立即再次尝试发送 ping,则即使网络不再关闭,它也会失败。 我检查了一个著名的网络协议分析器,发现只发送了有关第一个 dns 解析的请求。不发送第二次ping的dns解析请求。

为什么第二个 dns 请求没有发送? 此类 Windows Mobile 设备上是否有 dns 缓存机制? 如果是,这个机制可以通过编程方式刷新吗?

编辑:我放弃寻找此 DNS 刷新的解决方案。 我选择 ping IP 地址而不是名称机。 ping 硬编码地址 IP 的问题是我们必须 100% 确定该 IP 不会改变。 可以使用网关IP,因为它始终可达(如果不可达,则表示网络已关闭)。

My windows mobile application (written in C# with the compact framework) needs to know if a particular machine is active or not.

To achieve this goal, I thought to use a ping mechanism. I tried to use the Ping class implemented in the opennetcf framework (the System.Net.NetworkInformation.Ping class for the .NET Framework is not part of the compact framework).

Because I give to the Ping.Send function a host name, it first tries to resolve this host name and to retrieve an IP address.

But i observe the following problem :
If the first dns resolution fails (because the network is down at this moment), and if the application tries immediately again to send the ping, it fails too, even if the network is note down anymore.
I check with a famous network protocol analyzer and i saw that only the requests concerning the first dns resolution are sent. The requests concerning the dns resolution of the second ping are not sent.

Why is the second dns request not sent ?
Is there any dns cache mechanism on such Windows Mobile devices ?
If yes, can this mechanism beeing flushed programmatically ?

EDIT : I gave up finding a solution to this DNS flush.
I chose to ping an IP adress instead of a name machine.
The problem of pinging an hard coded adress IP is that we have to be 100% sure that this IP will not change.
The gateway IP can be used because it's always reachable (if it does not, it means the network is down).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谈场末日恋爱 2024-09-03 12:55:50

这是一个很好的问题,需要进行一些挖掘,

我知道这个答案可能会迟到,但请尝试一下

http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/7eda3979-6424-4702-89f4-1f586b613b01

This is a good question and took some digging

I know this answer may be late, but give it a try

http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/7eda3979-6424-4702-89f4-1f586b613b01

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文