如果你看看 iPhone,有很多关于如何执行可达性网络检查以及最佳实践的示例:
我发现了以下关于 SO 的现有问题:
我应该在哪里执行可达性检查?
iOS 4 可达性指南
iPhone 可达性检查
Apple 开发者,此外,还有一个如何使用其 Reachability 类的示例:
Apple 代码示例
我还没有看到资源WP7 还这样。 AppHub 的示例代码显示了与网络通信的项目,但没有一个(至少我看到)执行可达性检查。此外,虽然 Charles Pretzold 的免费 1000 页 PDF 有许多优秀的示例和解释,但没有其中涉及可达性。
有人这样做过或者找到了可靠的例子吗?
更新:有NetworkInterface.GetInternetInterfaceType() 已被证明可以在设备上运行?
If you look at the iPhone, there are many examples on how to perform reachability network checks as well as best practices:
I've found the following existing questions on SO:
Where should I perform a Reachability check?
Reachability Guide for iOS 4
iPhone reachability checking
Apple developers, in addition, have an example of how to use their Reachability class:
Apple Code Example
I haven't seen resources like this for WP7 yet. The AppHub's example code shows projects that communicate to the web, but none (at least that I saw) that perform reachability checks. In addition, though Charles Pretzold's free 1000 page PDF has many excellent examples and explanations, none of them concern reachability.
Has anyone done this yet or found solid examples?
UPDATE: Has NetworkInterface.GetInternetInterfaceType() been proven to work on devices?
发布评论
评论(1)
如果您想知道哪个网络连接当前处于活动状态,您可以执行此操作。
NetworkInterface.GetInternetInterfaceType方法 (Microsoft.Devices.NetworkInformation)
不确定这是否会给你带来你想要的东西。我知道您特别要求通过选定的网络连接进行可达性,但我想您最终可能会得到的结果是找出哪个网络连接处于活动状态..无论如何都要看看,看看它是否有帮助。
If you're wanting to know which network connection is currently active, you can do this.
NetworkInterface.GetInternetInterfaceType Method (Microsoft.Devices.NetworkInformation)
Not sure if that will give you what you're after though. I understand you specifically asked for reachability via a chosen network connection, but figured the result you might be after in the end is to work out which network connection is active.. have a look anyway and see if it helps.