1--TEST--
2Testing stream_get_meta_data() "blocked" 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 blocking to false:\n";
21var_dump(socket_set_blocking($client, 0));
22var_dump(stream_get_meta_data($client));
23
24echo "\n\nSet blocking to true:\n";
25var_dump(socket_set_blocking($client, 1));
26var_dump(stream_get_meta_data($client));
27
28fclose($client);
29fclose($socket);
30fclose($server);
31
32?>
33--EXPECTF--
34array(7) {
35  ["stream_type"]=>
36  string(%d) "tcp_socke%s"
37  ["mode"]=>
38  string(2) "r+"
39  ["unread_bytes"]=>
40  int(0)
41  ["seekable"]=>
42  bool(false)
43  ["timed_out"]=>
44  bool(false)
45  ["blocked"]=>
46  bool(true)
47  ["eof"]=>
48  bool(false)
49}
50
51
52Set blocking to false:
53bool(true)
54array(7) {
55  ["stream_type"]=>
56  string(%d) "tcp_socke%s"
57  ["mode"]=>
58  string(2) "r+"
59  ["unread_bytes"]=>
60  int(0)
61  ["seekable"]=>
62  bool(false)
63  ["timed_out"]=>
64  bool(false)
65  ["blocked"]=>
66  bool(false)
67  ["eof"]=>
68  bool(false)
69}
70
71
72Set blocking to true:
73bool(true)
74array(7) {
75  ["stream_type"]=>
76  string(%d) "tcp_socke%s"
77  ["mode"]=>
78  string(2) "r+"
79  ["unread_bytes"]=>
80  int(0)
81  ["seekable"]=>
82  bool(false)
83  ["timed_out"]=>
84  bool(false)
85  ["blocked"]=>
86  bool(true)
87  ["eof"]=>
88  bool(false)
89}
90