我面临网络可达性问题。
我使用了苹果提供的可达性类,并完成了所有必要的步骤来获得主机可达性。
它适用于任何有效的网站,例如:
- www.apple.com
- www.google.com
- 等等
对于所有这些站点,我曾经将主机可达性响应作为可达,但当我给出特定的IP(例如:http://196.12.125.34/)这是我检查主机可达性所要求的,它给出了否定的响应,即notReachable。
有人能提出可能是什么问题吗?
您需要对IP地址的可达性使用不同的方法:
对于主机名:
//reachabilityWithHostName- Use to check the reachability of a particular host name.
+ (Reachability*) reachabilityWithHostName: (NSString*) hostName;
对于IP地址:
//reachabilityWithAddress- Use to check the reachability of a particular IP address.
+ (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;