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