Search code examples
iosnsurlconnectionnsurlconnectiondelegatepersistent-connection

Async NSURLConnection and keep-alive


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.


Solution

  • 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.