Async NSURLConnection and keep-alive

让人想犯罪 __ 提交于 2019-12-12 17:25:10

问题


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.

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?

EDIT: packet sniffing on Mac. PacketLogger ships along with hardware tools.

EDIT2: looks like it doesn't capture iOS simulator's activity.


回答1:


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.



来源:https://stackoverflow.com/questions/20247930/async-nsurlconnection-and-keep-alive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!