Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / standard / tests / streams / stream_get_meta_data_socket_variation4.phpt
blobf9ef747987331cd8d24275ebc32b32d456121e51
1 --TEST--
2 Testing stream_get_meta_data() "eof" field on a udp socket
3 --FILE--
4 <?php
6 /* Setup socket server */
7 $server = stream_socket_server('tcp://127.0.0.1:31337');
9 /* Connect to it */
10 $client = fsockopen('tcp://127.0.0.1:31337');
11 if (!$client) {
12         die("Unable to create socket");
15 /* Accept that connection */
16 $socket = stream_socket_accept($server);
18 echo "Write some data:\n";
19 fwrite($socket, "abcdefg\n1234567\nxyzxyz\n");
20 var_dump(stream_get_meta_data($client));
22 echo "\n\nRead a line from the client:\n";
23 fgets($client);
24 var_dump(stream_get_meta_data($client));
26 echo "\n\nClose the server side socket and read the remaining data from the client:\n";
27 fclose($socket);
28 fclose($server);
29 while(!feof($client)) {
30         fread($client, 1);
32 var_dump(stream_get_meta_data($client));
34 fclose($client);
37 --EXPECTF--
38 Write some data:
39 array(7) {
40   ["stream_type"]=>
41   string(%d) "tcp_socke%s"
42   ["mode"]=>
43   string(2) "r+"
44   ["unread_bytes"]=>
45   int(%i)
46   ["seekable"]=>
47   bool(false)
48   ["timed_out"]=>
49   bool(false)
50   ["blocked"]=>
51   bool(true)
52   ["eof"]=>
53   bool(false)
57 Read a line from the client:
58 array(7) {
59   ["stream_type"]=>
60   string(%d) "tcp_socke%s"
61   ["mode"]=>
62   string(2) "r+"
63   ["unread_bytes"]=>
64   int(%i)
65   ["seekable"]=>
66   bool(false)
67   ["timed_out"]=>
68   bool(false)
69   ["blocked"]=>
70   bool(true)
71   ["eof"]=>
72   bool(false)
76 Close the server side socket and read the remaining data from the client:
77 array(7) {
78   ["stream_type"]=>
79   string(%d) "tcp_socke%s"
80   ["mode"]=>
81   string(2) "r+"
82   ["unread_bytes"]=>
83   int(%i)
84   ["seekable"]=>
85   bool(false)
86   ["timed_out"]=>
87   bool(false)
88   ["blocked"]=>
89   bool(true)
90   ["eof"]=>
91   bool(true)