title: stream socket client persistent how long does it stay open and how to confirm no duplicate connections
body: <p>We're using APNS for our app and after suddenly getting a lot of lag on connecting to the APNS servers I found out that we're supposed to leave the connection open.
  I have little understanding about how stream_socket_client works and can't seem to find the answers to these questions:</p>
  
  <ul>
  <li>We are sending notifications to 2 different apps with 2 different certificates, is the same connection reused for both is there one open for each?</li>
  <li>What is the lifespan of the connection? Does it automatically close or do we need to write in something that will close them from time to time?</li>
  <li>How do I review the number of open connections and their information to ensure that we don't end up with duplicates or too many open connections?</li>
  <li>Are their any advantages to using STREAM_CLIENT_ASYNC_CONNECT instead of STREAM_CLIENT_PERSISTENT? Is async also persistent?</li>
  </ul>
  
  <p>Here's the snippet of our connection code for your review, it is called every time a notification needs to be sent (we cannot batch notifications because our game is a turn-based word game - Wordspionage - with some tight time limits).</p>
  
  <p>stream_context_set_option($ctx, 'ssl', 'local_cert', $cert);
  stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);</p>
  
  <pre><code>// Open a connection to the APNS server
  $url = 'ssl://gateway.push.apple.com:2195';
  
  $fp = stream_socket_client(
      $url , $err,
      $errstr, 4, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
  </code></pre>
  
  <p>Thanks for the help!</p>