<small id='eCiTd'></small><noframes id='eCiTd'>

    1. <legend id='eCiTd'><style id='eCiTd'><dir id='eCiTd'><q id='eCiTd'></q></dir></style></legend>

    2. <tfoot id='eCiTd'></tfoot>
    3. <i id='eCiTd'><tr id='eCiTd'><dt id='eCiTd'><q id='eCiTd'><span id='eCiTd'><b id='eCiTd'><form id='eCiTd'><ins id='eCiTd'></ins><ul id='eCiTd'></ul><sub id='eCiTd'></sub></form><legend id='eCiTd'></legend><bdo id='eCiTd'><pre id='eCiTd'><center id='eCiTd'></center></pre></bdo></b><th id='eCiTd'></th></span></q></dt></tr></i><div id='eCiTd'><tfoot id='eCiTd'></tfoot><dl id='eCiTd'><fieldset id='eCiTd'></fieldset></dl></div>

        <bdo id='eCiTd'></bdo><ul id='eCiTd'></ul>

      确定 iPhone 是真正连接到互联网还是仅在受限热点后面

      时间:2023-10-05
      <tfoot id='ZNFpu'></tfoot>
        <bdo id='ZNFpu'></bdo><ul id='ZNFpu'></ul>

          • <legend id='ZNFpu'><style id='ZNFpu'><dir id='ZNFpu'><q id='ZNFpu'></q></dir></style></legend>

                  <tbody id='ZNFpu'></tbody>
              1. <i id='ZNFpu'><tr id='ZNFpu'><dt id='ZNFpu'><q id='ZNFpu'><span id='ZNFpu'><b id='ZNFpu'><form id='ZNFpu'><ins id='ZNFpu'></ins><ul id='ZNFpu'></ul><sub id='ZNFpu'></sub></form><legend id='ZNFpu'></legend><bdo id='ZNFpu'><pre id='ZNFpu'><center id='ZNFpu'></center></pre></bdo></b><th id='ZNFpu'></th></span></q></dt></tr></i><div id='ZNFpu'><tfoot id='ZNFpu'></tfoot><dl id='ZNFpu'><fieldset id='ZNFpu'></fieldset></dl></div>

                <small id='ZNFpu'></small><noframes id='ZNFpu'>

              2. 本文介绍了确定 iPhone 是真正连接到互联网还是仅在受限热点后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我在严格识别 iPhone 的网络访问类型方面遇到了很多麻烦.我在 StackOverflow 上看到过很多这样的问题,但没有一个对我有帮助.例如我已经看到了这个:如何在 iOS 或 OSX 上检查活动的 Internet 连接?

                I'm having quite a lot of trouble on identifying rigorously the kind of network access an iPhone has. I have seen many questions like this one on StackOverflow but none of them helped me. For example I have already seen this: How to check for an active Internet connection on iOS or OSX?

                但我想确切知道以下 3 种情况何时发生:

                But I want to know precisely when the 3 following cases occur:

                1. Wifi 3G 已禁用

                Wifi 3G 已启用,但没有没有互联网连接.这可能是由于 3G 没有真正工作,即使它显示在状态栏上,或者 WiFi 是在让您访问 Internet 之前要求登录的热点或最后一个场景:WiFi 源是本地网络,但确实不提供任何互联网连接.

                Wifi or 3G are enabled but there is no internet connection. It could be due to 3G not really working, even though it is showing up on the status bar, or the WiFi is a hotspot asking to log in before letting you access the Internet or last scenario: The WiFi source is a local network but does not provide any Internet connection.

                一切正常

                当然,我尝试过各种各样的东西,例如:

                Of course I have tried various stuff, like this for instance:

                // Allocate a reachability object
                Reachability* reach = [Reachability reachabilityWithHostname:@"www.google.com"];
                
                // Set the blocks
                reach.reachableBlock = ^(Reachability*reach)
                {
                    /* NOT REACHABLE */
                    dispatch_async(dispatch_get_main_queue(), ^{
                        iarcSBInternetWarning.visible = NO;
                    });
                };
                
                reach.unreachableBlock = ^(Reachability*reach)
                {
                    /* REACHABLE */
                    iarcSBInternetWarning.visible = YES;
                };
                
                // Start the notifier, which will cause the reachability object to retain itself
                [reach startNotifier];
                

                但这似乎只是表示 Wifi 或 3G 是否已启用,并且不会检查可能的互联网限制.如果任何答案能帮助我确定这三种情况,我都会非常高兴.

                But this seems just to say wether Wifi or 3G are enabled and does not check for possible internet restrictions. I would be highly delighted by any answer helping me identifying the three scenarios.

                当然,分析来自返回特定字节序列的个人服务器 API 的直接 HTTP 请求输出是可行的,但这不是我想做的.我更喜欢使用任何类型的可达性 API.

                Of course analyzing a direct HTTP request output from a personal server API returning a specific byte sequence would work but that is not what I would like to do. I'd prefer using any kind of Reachability API.

                我使用了 Apple 的可达性 API,它似乎无法识别热点重定向.

                I've used Apple's reachability API, it does not seem to recognize hotspot redirections.

                如果使用 Reachability API 无法做到这一点,那么向服务器发出简单请求的最低资源消耗方法是什么,请检查它在指定的超时之前是否可以访问,以及 URL 是否未重定向到热点登录页面(可能只检查标题,而不是整个服务器字节序列输出)?每 15 秒运行一次这样的脚本是个好主意,还是会消耗过多的电池和/或网络数据?

                If this is not possible with the Reachability APIs, then what would be the lowest resource-consuming method to make a simple request to a server, check that it is reachable before a specified timeout, and that the URL was not redirected to a hotspot login page (maybe only check the headers, not the whole server byte sequence output)? Is it a good idea to run such a script every 15 seconds, or would it use too much battery and/or network data?

                推荐答案

                检查出站连接最简单的方法是 GET Google 的 generate204 页面并检查响应代码

                The simplest method to check outbound connectivity is to GET Google's generate204 page and check the response code

                http://www.google.com/generate_204

                或者你可以使用

                http://www.apple.com/library/test/success.html 这是操作系统使用的页面

                http://www.apple.com/library/test/success.html which is the page the OS uses

                这篇关于确定 iPhone 是真正连接到互联网还是仅在受限热点后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:android 解析 .local (mDNS) 下一篇:禁用 NSOutputStream 的 Nagle 算法

                相关文章

              3. <legend id='JFE2j'><style id='JFE2j'><dir id='JFE2j'><q id='JFE2j'></q></dir></style></legend>

                  <bdo id='JFE2j'></bdo><ul id='JFE2j'></ul>
              4. <small id='JFE2j'></small><noframes id='JFE2j'>

                <i id='JFE2j'><tr id='JFE2j'><dt id='JFE2j'><q id='JFE2j'><span id='JFE2j'><b id='JFE2j'><form id='JFE2j'><ins id='JFE2j'></ins><ul id='JFE2j'></ul><sub id='JFE2j'></sub></form><legend id='JFE2j'></legend><bdo id='JFE2j'><pre id='JFE2j'><center id='JFE2j'></center></pre></bdo></b><th id='JFE2j'></th></span></q></dt></tr></i><div id='JFE2j'><tfoot id='JFE2j'></tfoot><dl id='JFE2j'><fieldset id='JFE2j'></fieldset></dl></div>
                1. <tfoot id='JFE2j'></tfoot>