title: lock screen interrupts NSURLConnection
body: <p>I'd like to know what's happening behind the scenes when the user locks and unlocks the iPad screen. I have an app that downloads files using NSURLConnection and the downloads fail with a SOAP error ("A server with the specified hostname could not be found"), but not when the user locks the screen, but when it unlocks it.
  Regardless of the fact when the error pops up, the download never finishes. Any ideas why and what could be done about it ?</p>
  
  <pre><code>NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:300];
  
  NSURLConnection* conn = [[NSURLConnection alloc] initWithRequest: request delegate: self];
  </code></pre>
  
  <p>From what I can tell, when I hit the Home button I get:</p>
  
  <pre><code>applicationWillResignActive
  applicationDidEnterBackground
  </code></pre>
  
  <p>and after I recall the app after three minutes I get:</p>
  
  <pre><code>applicationWillEnterForeground
  </code></pre>
  
  <p>and the download is either already finished or has progressed even in the background.</p>
  
  <p>When I leave it in the background longer (5 minutes) it times out with an error.</p>
  
  <p>When I lock the screen I get the same order of application states, but also an error message about the download disconnection.</p>
  
  <p>Thank you!</p>