简体   繁体   English

轮询网络以确定网络是否可访问?

[英]Polling network to determine whether network is reachable?

I was trying to implement ASIHTTPRequest to download files from a server. 我试图实现ASIHTTPRequest以从服务器下载文件。 I have an option were user can add downloads to a queue and ASINetworkQueue handles the file downloads one by one. 我有一个选项,用户可以将下载内容添加到队列中,而ASINetworkQueue处理文件下载。

I am trying to implement a feature wherein, if the user loses their network connection, my ASINetworkQueue should poll for network reachability continuously. 我正在尝试实现一项功能,如果用户失去网络连接,我的ASINetworkQueue应该连续轮询网络可达性。 Once connectivity is available again, the application starts downloading files from where it left off. 连接再次可用后,该应用程序将从上次中断的地方开始下载文件。

I am not asking for code, But I would appreciate if someone can help me with a array of hints. 我不是在请求代码,但是如果有人可以帮助我提供一些提示,我将不胜感激。


To make my application download the file from where it left off, I am using the ASIHTTPRequest method 为了使我的应用程序从中断处下载文件,我使用了ASIHTTPRequest方法

 [request setAllowResumeForFileDownloads:YES]; 

You can use the Reachability APIs that apple provides illustrated in their Reachability sample code. 您可以使用Apple提供的Reachability API(在其Reachability示例代码中说明)。 See link. 见链接。

It allows you to receive callback when reachability changes, you can also poll reachability when appropriate, such as on applicationDidBecomeActive when if the reachability has changed when you were in the background you wouldn't have been informed. 它使您可以在可达性发生变化时接收回调,也可以在适当时(例如在applicationDidBecomeActive上)查询可达性,当您处于后台时,如果可达性发生了变化,则不会收到通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM