Annotation of embedaddon/php/ext/sockets/tests/socket_import_stream-4.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: socket_import_stream: effects of closing
3: --SKIPIF--
4: <?php
5: if (!extension_loaded('sockets')) {
6: die('SKIP sockets extension not available.');
7: }
1.1.1.2 ! misho 8: if(substr(PHP_OS, 0, 3) == 'WIN' ) {
! 9: die("skip Not Valid for Windows");
! 10: }
1.1 misho 11: --FILE--
12: <?php
13:
14: function test($stream, $sock) {
15: if ($stream !== null) {
16: echo "stream_set_blocking ";
17: print_r(stream_set_blocking($stream, 0));
18: echo "\n";
19: }
20: if ($sock !== null) {
21: echo "socket_set_block ";
22: print_r(socket_set_block($sock));
23: echo "\n";
24: echo "socket_get_option ";
25: print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE));
26: echo "\n";
27: }
28: echo "\n";
29: }
30:
31: echo "normal\n";
32: $stream0 = stream_socket_server("udp://0.0.0.0:58380", $errno, $errstr, STREAM_SERVER_BIND);
33: $sock0 = socket_import_stream($stream0);
34: test($stream0, $sock0);
35:
36: echo "\nunset stream\n";
37: $stream1 = stream_socket_server("udp://0.0.0.0:58381", $errno, $errstr, STREAM_SERVER_BIND);
38: $sock1 = socket_import_stream($stream1);
39: unset($stream1);
40: test(null, $sock1);
41:
42: echo "\nunset socket\n";
43: $stream2 = stream_socket_server("udp://0.0.0.0:58382", $errno, $errstr, STREAM_SERVER_BIND);
44: $sock2 = socket_import_stream($stream2);
45: unset($sock2);
46: test($stream2, null);
47:
48: echo "\nclose stream\n";
49: $stream3 = stream_socket_server("udp://0.0.0.0:58383", $errno, $errstr, STREAM_SERVER_BIND);
50: $sock3 = socket_import_stream($stream3);
51: fclose($stream3);
52: test($stream3, $sock3);
53:
54: echo "\nclose socket\n";
55: $stream4 = stream_socket_server("udp://0.0.0.0:58384", $errno, $errstr, STREAM_SERVER_BIND);
56: $sock4 = socket_import_stream($stream4);
57: socket_close($sock4);
58: test($stream4, $sock4);
59:
60: echo "Done.\n";
61: --EXPECTF--
62: normal
63: stream_set_blocking 1
64: socket_set_block 1
65: socket_get_option 2
66:
67:
68: unset stream
69: socket_set_block 1
70: socket_get_option 2
71:
72:
73: unset socket
74: stream_set_blocking 1
75:
76:
77: close stream
78: stream_set_blocking
79: Warning: stream_set_blocking(): %d is not a valid stream resource in %s on line %d
80:
81: socket_set_block
82: Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d
83:
84: socket_get_option
85: Warning: socket_get_option(): unable to retrieve socket option [%d]: %s in %s on line %d
86:
87:
88:
89: close socket
90: stream_set_blocking
91: Warning: stream_set_blocking(): %d is not a valid stream resource in %s on line %d
92:
93: socket_set_block
94: Warning: socket_set_block(): %d is not a valid Socket resource in %s on line %d
95:
96: socket_get_option
97: Warning: socket_get_option(): %d is not a valid Socket resource in %s on line %d
98:
99:
100: Done.
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>