1--TEST-- 2Test stream_set_timeout() function : error conditions 3--FILE-- 4<?php 5echo "*** Testing stream_set_timeout() : error conditions ***\n"; 6 7for ($i=0; $i<100; $i++) { 8 $port = rand(10000, 65000); 9 /* Setup socket server */ 10 $server = @stream_socket_server("tcp://127.0.0.1:$port"); 11 if ($server) { 12 break; 13 } 14} 15/* Connect to it */ 16$client = fsockopen("tcp://127.0.0.1:$port"); 17 18$seconds = 10; 19$microseconds = 10; 20 21echo "\n-- Testing stream_set_timeout() function with a closed socket --\n"; 22fclose($client); 23try { 24 var_dump( stream_set_timeout($client, $seconds) ); 25} catch (TypeError $e) { 26 echo $e->getMessage(), "\n"; 27} 28 29echo "\n-- Testing stream_set_timeout() function with a stream that does not support timeouts --\n"; 30$filestream = fopen(__FILE__, "r"); 31var_dump( stream_set_timeout($filestream, $seconds) ); 32 33fclose($filestream); 34fclose($server); 35 36echo "Done"; 37?> 38--EXPECT-- 39*** Testing stream_set_timeout() : error conditions *** 40 41-- Testing stream_set_timeout() function with a closed socket -- 42stream_set_timeout(): supplied resource is not a valid stream resource 43 44-- Testing stream_set_timeout() function with a stream that does not support timeouts -- 45bool(false) 46Done 47