title: How to encrypt non-blocking PHP socket streams?
body: <p>I am attempting to use PHP's stream_socket_client() function in a non-blocking (asynchronous) fashion. Documentation on PHP's web site indicates that the STREAM_CLIENT_ASYNC_CONNECT option flag should enable this. However, the following code...</p>
  
  <pre><code>$start_time = microtime(true);
  $sockets[$i] = stream_socket_client('ssl://74.125.47.109:993', $errint, $errstr, 1, STREAM_CLIENT_ASYNC_CONNECT);
  $end_time = microtime(true);
  echo "Total time taken: " . ($end_time-$start_time) . " secs.";
  </code></pre>
  
  <p>Outputs the following:</p>
  
  <pre><code>Total time taken: 0.76204109191895 secs.
  </code></pre>
  
  <p>Evidently, the function is blocking (also supported by the fact that omission of the STREAM_CLIENT_ASYC_CONNECT flag does not meaningfully change the "total time taken" script output.</p>
  
  <p>Any ideas on why this may be happening, and how to enforce a non-blocking connection attempt?</p>