iOS 网络可达性 - 似乎不起作用 [英] iOS network reachability - doesn't seem to be working

查看:24
本文介绍了iOS 网络可达性 - 似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 如何检查对于 iOS 或 OSX 上的有效互联网连接?http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html 来测试连接性,但我遇到了一些非常基本的问题.

I'm following How to check for an active Internet connection on iOS or OSX? and http://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html to test for connectivity, but am running into some pretty basic issues.

例如,我正在另一台机器上运行 .NET API,然后尝试通过我的 mac mini 连接到它.

For example, I'm running a .NET API off of another machine and then trying to connect to it via my mac mini.

1) 当 IIS 运行时,一切都像它应该的那样工作,我很高兴我能正常工作!

1) When IIS is running, everything is working like it should, I was excited that I got this working!

2) 我可以完全关闭 IIS(显然,主机无法访问)但我的reachabilityWithHostName 仍然报告主机可以访问.

2) I can shut off IIS completely (obviously, host is unreachable) but my reachabilityWithHostName is still reporting that the host is reachable.

有什么想法吗?

推荐答案

SCNetworkReachability 参考.

SCNetworkReachability 编程接口允许应用程序确定系统的状态当前网络配置和目标主机的可达性.A远程主机被认为是可达的当一个数据包,由一个应用程序进入网络堆栈,可以离开本地设备.可达性并不能保证数据包实际上是主办方收到.

The SCNetworkReachability programming interface allows an application to determine the status of a system's current network configuration and the reachability of a target host. A remote host is considered reachable when a data packet, sent by an application into the network stack, can leave the local device. Reachability does not guarantee that the data packet will actually be received by the host.

打开和关闭 IIS 只是阻止您的服务器接收 web 请求,例如 ftp/http,并不会阻止设备成功发送数据包.

Turning IIS on and off is just preventing your server from receiving web request such as ftp/http and does not stop the device from successfully sending a data packet out.

这篇关于iOS 网络可达性 - 似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆