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