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