轮询网络以确定网络是否可达?
我试图实现 ASIHTTPRequest
从服务器下载文件。我有一个选项,用户可以将下载添加到队列中,并且 ASINetworkQueue
逐一处理文件下载。
我正在尝试实现一项功能,其中,如果用户失去网络连接,我的 ASINetworkQueue
应持续轮询网络可达性。一旦连接再次可用,应用程序就会开始从上次中断的位置下载文件。
我不是要求代码,但如果有人可以帮助我提供一系列提示,我将不胜感激。
To make my application download the file from where it left off, I am using the
ASIHTTPRequest
method[request setAllowResumeForFileDownloads:YES];
I was trying to implement ASIHTTPRequest
to download files from a server. I have an option were user can add downloads to a queue and ASINetworkQueue
handles the file downloads one by one.
I am trying to implement a feature wherein, if the user loses their network connection, my ASINetworkQueue
should poll for network reachability continuously. 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[request setAllowResumeForFileDownloads:YES];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Apple 提供的 Reachability 示例代码中说明的 Reachability API 。请参阅链接。
它允许您在可达性发生变化时接收回调,您还可以在适当的时候轮询可达性,例如在 applicationDidBecomeActive 上,如果您在后台时可达性发生变化,您将不会收到通知。
You can use the Reachability APIs that apple provides illustrated in their Reachability sample code. 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.