Advertisement
d34n

PHP bug #61285 test script

Mar 6th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2. # SSL connections do not timeout
  3. # https://bugs.php.net/bug.php?id=61285
  4.  
  5. test('php.net:80');
  6. test('ssl://php.net:443');
  7.  
  8.  
  9. function test($host){
  10.         $socket = stream_socket_client($host, $errno, $errstr, 15);
  11.         echo "connect to $host errno=$errno errstr=$errstr\n";
  12.         if($socket && $errno==0) echo "connected\n"; else echo "connection error\n";
  13.         stream_set_timeout($socket,5);
  14.         $connect_time=time();
  15.  
  16.         while($data=fgets($socket)) echo "DATA=$data";
  17.  
  18.         $meta=stream_get_meta_data($socket);
  19.         if($meta['timed_out']){
  20.                 $timed=time()-$connect_time;
  21.                 echo "timed out after $timed seconds\n";
  22.         }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement