2 Test stream_set_timeout() function : error conditions
5 /* Prototype : proto bool stream_set_timeout(resource stream, int seconds, int microseconds)
6 * Description: Set timeout on stream read to seconds + microseonds
7 * Source code: ext/standard/streamsfuncs.c
8 * Alias to functions: socket_set_timeout
11 echo "*** Testing stream_set_timeout() : error conditions ***\n";
13 for ($i=0; $i<100; $i++) {
14 $port = rand(10000, 65000);
15 /* Setup socket server */
16 $server = @stream_socket_server("tcp://127.0.0.1:$port");
22 $client = fsockopen("tcp://127.0.0.1:$port");
27 echo "\n-- Testing stream_set_timeout() function with a closed socket --\n";
30 var_dump( stream_set_timeout($client, $seconds) );
31 } catch (TypeError $e) {
32 echo $e->getMessage(), "\n";
35 echo "\n-- Testing stream_set_timeout() function with a stream that does not support timeouts --\n";
36 $filestream = fopen(__FILE__, "r");
37 var_dump( stream_set_timeout($filestream, $seconds) );
45 *** Testing stream_set_timeout() : error conditions ***
47 -- Testing stream_set_timeout() function with a closed socket --
48 stream_set_timeout(): supplied resource is not a valid stream resource
50 -- Testing stream_set_timeout() function with a stream that does not support timeouts --