问题
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