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 //Test stream_set_timeout with one more than the expected number of arguments
14 echo "\n-- Testing stream_set_timeout() function with more than expected no. of arguments --\n";
16 /* Setup socket server */
17 $server = stream_socket_server('tcp://127.0.0.1:31337');
19 $client = fsockopen('tcp://127.0.0.1:31337');
24 var_dump( stream_set_timeout($client, $seconds, $microseconds, $extra_arg) );
26 // Testing stream_set_timeout with one less than the expected number of arguments
27 echo "\n-- Testing stream_set_timeout() function with less than expected no. of arguments --\n";
30 var_dump( stream_set_timeout($client) );
33 echo "\n-- Testing stream_set_timeout() function with a closed socket --\n";
35 var_dump( stream_set_timeout($client, $seconds) );
37 echo "\n-- Testing stream_set_timeout() function with an invalid stream --\n";
38 var_dump( stream_set_timeout($seconds, $seconds) );
40 echo "\n-- Testing stream_set_timeout() function with a stream that does not support timeouts --\n";
41 $filestream = fopen(__FILE__, "r");
42 var_dump( stream_set_timeout($filestream, $seconds) );
50 *** Testing stream_set_timeout() : error conditions ***
52 -- Testing stream_set_timeout() function with more than expected no. of arguments --
54 Warning: stream_set_timeout() expects at most 3 parameters, 4 given in %s on line %i
57 -- Testing stream_set_timeout() function with less than expected no. of arguments --
59 Warning: stream_set_timeout() expects at least 2 parameters, 1 given in %s on line %i
62 -- Testing stream_set_timeout() function with a closed socket --
64 Warning: stream_set_timeout(): %i is not a valid stream resource in %s on line %i
67 -- Testing stream_set_timeout() function with an invalid stream --
69 Warning: stream_set_timeout() expects parameter 1 to be resource, integer given in %s on line %i
72 -- Testing stream_set_timeout() function with a stream that does not support timeouts --