所需 URL 的网络可达性

发布于 2024-12-27 17:44:29 字数 338 浏览 3 评论 0原文

我面临网络可达性问题。

我已经使用了苹果提供的可达性类,并完成了所有必要的步骤来获得主机的可达性。

它适用于任何有效的网站,例如:

  • www.apple.com
  • www.google.com
  • 等。

对于所有这些网站,我曾经将主机可达性响应视为可达,但是当我给出特定的 IP 时(例如: http://196.12.125.34/) 这是我检查主机可达性所必需的,它给出了否定响应,即不可达。

谁能建议可能是什么问题?

I am facing a issue on network reachability.

I have used the reachability class provided by apple and have done all necessary steps to get the host reachability.

It works fine for any valid site eg.:

  • www.apple.com
  • www.google.com
  • etc.

For all these sites i used to get the host reachability response as reachable, but when I give a specific IP(eg: http://196.12.125.34/) which is required by me to check for the hostReachability it gives negative response i.e notReachable.

Can anyone suggest what may be the issue?

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

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

发布评论

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

评论(1

︶ ̄淡然 2025-01-03 17:44:29

您需要对 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;

You need to use a different method on Reachability for IP Address:

For host name:

//reachabilityWithHostName- Use to check the reachability of a particular host name. 
+ (Reachability*) reachabilityWithHostName: (NSString*) hostName;

For IP Address:

//reachabilityWithAddress- Use to check the reachability of a particular IP address. 
+ (Reachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文