1

I've just developed a library in Swift which is posting data to a specific server. I open the connection with NSURLSession.sharedSession().dataTaskWithRequest(request). Now I was wondering if I have to handle the closing of this connection or does the task close the connection itself after some time?

ph1psG
  • 568
  • 5
  • 24

1 Answers1

2

NSURLSession and NSURLConnection both use a shared connection pool, reusing existing connections for future requests to reduce overhead, and periodically closing old connections that are no longer in use. So no, there's nothing you have to do to ensure that connections get closed.

dgatwood
  • 10,129
  • 1
  • 28
  • 49