title: php stream_socket_client timeout does not work as expected
body: <p>i have written a class which checks ssl vertificates via php stream_socket_client. </p>
  
  <p>however timeout does not work for some sites. the scripts sometimes wait up to 60 seconds for response of some hosts (seems to be a php configuration limit). </p>
  
  <p>this is confusing because i set the (connect) timeout to 2 seconds. for the ssl transport i do not see any other limits i can set to reduce the max connection time/ transfer time. are there any other time limits i can use?</p>
  
  <pre><code>    $options = array( 
          "ssl" =&gt; array(
          "capture_peer_cert"       =&gt; true,
          "capture_peer_chain"      =&gt; true,
          "capture_peer_cert_chain" =&gt; true, 
          "verify_peer"             =&gt; $verify_peer,  
          "allow_self_signed"       =&gt; $allow_self_signed )
      );
  
      if (strlen($this-&gt;cafile) &gt; 0) {
          $options['ssl']['cafile'] = $this-&gt;cafile;
          if (strlen($this-&gt;capath) &gt; 0 &amp;&amp; [..]) {
              $options['ssl']['capath'] = $this-&gt;capath;
          }
      } else {
          $options['verify_peer'] = false;
      }
  
      $get = @stream_context_create( $options);
  
      $read = @stream_socket_client("ssl://$host:443", $errno, $errstr, 2, STREAM_CLIENT_CONNECT, $get);
  
      if($read){
          stream_set_timeout($read, 2);
          $cert = stream_context_get_params($read);
      } else {
          $cert = false;
      }       
  </code></pre>