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(8) {
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  ["uri"]=>
50  string(21) "tcp://127.0.0.1:31333"
51}
52
53
54Set blocking to false:
55bool(true)
56array(8) {
57  ["timed_out"]=>
58  bool(false)
59  ["blocked"]=>
60  bool(false)
61  ["eof"]=>
62  bool(false)
63  ["stream_type"]=>
64  string(%d) "tcp_socke%s"
65  ["mode"]=>
66  string(2) "r+"
67  ["unread_bytes"]=>
68  int(0)
69  ["seekable"]=>
70  bool(false)
71  ["uri"]=>
72  string(21) "tcp://127.0.0.1:31333"
73}
74
75
76Set blocking to true:
77bool(true)
78array(8) {
79  ["timed_out"]=>
80  bool(false)
81  ["blocked"]=>
82  bool(true)
83  ["eof"]=>
84  bool(false)
85  ["stream_type"]=>
86  string(%d) "tcp_socke%s"
87  ["mode"]=>
88  string(2) "r+"
89  ["unread_bytes"]=>
90  int(0)
91  ["seekable"]=>
92  bool(false)
93  ["uri"]=>
94  string(21) "tcp://127.0.0.1:31333"
95}
96