1--TEST--
2Testing stream_get_meta_data() "timed_out" field on a udp socket
3--FILE--
4<?php
5
6/* Setup socket server */
7$server = stream_socket_server('tcp://127.0.0.1:31337');
8
9/* Connect to it */
10$client = fsockopen('tcp://127.0.0.1:31337');
11if (!$client) {
12	die("Unable to create socket");
13}
14
15/* Accept that connection */
16$socket = stream_socket_accept($server);
17
18var_dump(stream_get_meta_data($client));
19
20echo "\n\nSet a timeout on the client and attempt a read:\n";
21socket_set_timeout($client, 0, 1000);
22fread($client, 1);
23var_dump(stream_get_meta_data($client));
24
25echo "\n\nWrite some data from the server:\n";
26fwrite($socket, "12345");
27var_dump(stream_get_meta_data($client));
28
29echo "\n\nRead some data from the client:\n";
30fread($client, 5);
31var_dump(stream_get_meta_data($client));
32
33fclose($client);
34fclose($socket);
35fclose($server);
36
37?>
38--EXPECTF--
39array(7) {
40  ["stream_type"]=>
41  string(%d) "tcp_socke%s"
42  ["mode"]=>
43  string(2) "r+"
44  ["unread_bytes"]=>
45  int(0)
46  ["seekable"]=>
47  bool(false)
48  ["timed_out"]=>
49  bool(false)
50  ["blocked"]=>
51  bool(true)
52  ["eof"]=>
53  bool(false)
54}
55
56
57Set a timeout on the client and attempt a read:
58array(7) {
59  ["stream_type"]=>
60  string(%d) "tcp_socke%s"
61  ["mode"]=>
62  string(2) "r+"
63  ["unread_bytes"]=>
64  int(0)
65  ["seekable"]=>
66  bool(false)
67  ["timed_out"]=>
68  bool(true)
69  ["blocked"]=>
70  bool(true)
71  ["eof"]=>
72  bool(false)
73}
74
75
76Write some data from the server:
77array(7) {
78  ["stream_type"]=>
79  string(%d) "tcp_socke%s"
80  ["mode"]=>
81  string(2) "r+"
82  ["unread_bytes"]=>
83  int(0)
84  ["seekable"]=>
85  bool(false)
86  ["timed_out"]=>
87  bool(true)
88  ["blocked"]=>
89  bool(true)
90  ["eof"]=>
91  bool(false)
92}
93
94
95Read some data from the client:
96array(7) {
97  ["stream_type"]=>
98  string(%d) "tcp_socke%s"
99  ["mode"]=>
100  string(2) "r+"
101  ["unread_bytes"]=>
102  int(0)
103  ["seekable"]=>
104  bool(false)
105  ["timed_out"]=>
106  bool(false)
107  ["blocked"]=>
108  bool(true)
109  ["eof"]=>
110  bool(false)
111}
112