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