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:31333');
8
9/* Connect to it */
10$client = fsockopen('tcp://127.0.0.1:31333');
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  ["timed_out"]=>
36  bool(false)
37  ["blocked"]=>
38  bool(true)
39  ["eof"]=>
40  bool(false)
41  ["stream_type"]=>
42  string(%d) "tcp_socke%s"
43  ["mode"]=>
44  string(2) "r+"
45  ["unread_bytes"]=>
46  int(0)
47  ["seekable"]=>
48  bool(false)
49}
50
51
52Set blocking to false:
53bool(true)
54array(7) {
55  ["timed_out"]=>
56  bool(false)
57  ["blocked"]=>
58  bool(false)
59  ["eof"]=>
60  bool(false)
61  ["stream_type"]=>
62  string(%d) "tcp_socke%s"
63  ["mode"]=>
64  string(2) "r+"
65  ["unread_bytes"]=>
66  int(0)
67  ["seekable"]=>
68  bool(false)
69}
70
71
72Set blocking to true:
73bool(true)
74array(7) {
75  ["timed_out"]=>
76  bool(false)
77  ["blocked"]=>
78  bool(true)
79  ["eof"]=>
80  bool(false)
81  ["stream_type"]=>
82  string(%d) "tcp_socke%s"
83  ["mode"]=>
84  string(2) "r+"
85  ["unread_bytes"]=>
86  int(0)
87  ["seekable"]=>
88  bool(false)
89}
90