Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # SSL connections do not timeout
- # https://bugs.php.net/bug.php?id=61285
- test('php.net:80');
- test('ssl://php.net:443');
- function test($host){
- $socket = stream_socket_client($host, $errno, $errstr, 15);
- echo "connect to $host errno=$errno errstr=$errstr\n";
- if($socket && $errno==0) echo "connected\n"; else echo "connection error\n";
- stream_set_timeout($socket,5);
- $connect_time=time();
- while($data=fgets($socket)) echo "DATA=$data";
- $meta=stream_get_meta_data($socket);
- if($meta['timed_out']){
- $timed=time()-$connect_time;
- echo "timed out after $timed seconds\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement