异步NSURLConnection并保持活动状态 [英] Async NSURLConnection and keep-alive
问题描述
我正在使用NSURLConnection异步执行对同一主机的一系列HTTP请求,即e.和[initWithRequest:delegate:startImmediately:]
和一个委托.
I'm using NSURLConnection to perform a series of HTTP requests to the same host asynchronously, i. e. with [initWithRequest:delegate:startImmediately:]
and a delegate.
当向代理发出connectionDidFinishLoading
通知时,我释放连接对象,然后初始化并启动另一个对象,并将其发送到同一主机.问题-基础套接字会被重用吗? Connection:keep-alive
服务器标头在那里,但是我无法确保它受到尊重.我的意思是,当发出通知时,第一个连接尚未正式完成".是吗?
When connectionDidFinishLoading
notification comes to the delegate, I release my connection object, then initialize and initiate another one, to the same host. Question - will the underlying socket be reused? The Connection:keep-alive
server header is there, but I have no way of making sure that it's being respected. I mean, the first connection is not officially "done" yet when it issues the notification. Or is it?
在Mac上进行数据包嗅探. PacketLogger随硬件工具一起提供.
packet sniffing on Mac. PacketLogger ships along with hardware tools.
看起来它无法捕获iOS模拟器的活动.
looks like it doesn't capture iOS simulator's activity.
推荐答案
摆弄一番之后,让Wireshark在Mac上运行.请求之间的TCP对话是不间断的-对我来说,这表明保持活动的连接正在按通告的方式工作.模拟器上的iOS 7.0.3.
After some fiddling, got Wireshark to work on Mac. The TCP conversation is unbroken between requests - to me, this suggests keep-alive connections are working as advertised. iOS 7.0.3 on simulator.
这篇关于异步NSURLConnection并保持活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!