将NSURLConnection绑定到特定接口 [英] Binding NSURLConnection to specific interface

查看:92
本文介绍了将NSURLConnection绑定到特定接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个小型iOS应用程序,该应用程序必须使用HTTP从服务器下载一些文件.在某些情况下,希望通过默认接口以外的其他接口来执行此操作(即使用3G而非Wifi).

I am working on a small iOS application which has to download some files from a server using HTTP. In some cases, it is desirable to do this over another interface than the default (i.e., use 3G rather than Wifi).

当前,我使用NSURLConnection(和其他NSURL类)来检索文件.但是,我还没有找到将这种连接绑定到特定接口/套接字的方法.我已经为每个接口成功创建了活动套接字(使用普通的BSD套接字调用).

Currently, I use the NSURLConnection (and the other NSURL-classes) to retrieve the files. However, I have not found a way to bind this connection to a specific interface/socket. I have successfully created active sockets for each interface (using the normal BSD socket-calls).

是否有任何方法可以配置NSURLConnection以使用这些套接字,或者有另一种方法来强制它使用特定的网络接口?还是我使用CFNetwork的唯一选择(我想做尽可能少的与HTTP有关的工作:))?

Is there any way to configure NSURLConnection to use these sockets, or another way to force it to use a specific network interface? Or is my only option to use CFNetwork (I want to do as little work as possible related to HTTP :))?

推荐答案

查看可达性"示例,它可以告诉您是否可以通过wwan,wifi到达目标主机.

Check out the Reachability example, it can tell you if your target host is reachable via wwan, wifi or not at all.

这篇关于将NSURLConnection绑定到特定接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆