1--TEST-- 2socket_import_stream: effects of closing 3--EXTENSIONS-- 4sockets 5--SKIPIF-- 6<?php 7 8if(substr(PHP_OS, 0, 3) != 'WIN' ) { 9 die("skip Not Valid for Linux"); 10} 11?> 12--FILE-- 13<?php 14 15function test($stream, $sock) { 16 if ($stream !== null) { 17 echo "stream_set_blocking "; 18 try { 19 print_r(stream_set_blocking($stream, 0)); 20 } catch (Error $e) { 21 echo get_class($e), ": ", $e->getMessage(), "\n"; 22 } 23 echo "\n"; 24 } 25 if ($sock !== null) { 26 echo "socket_set_block "; 27 try { 28 print_r(socket_set_block($sock)); 29 } catch (Error $e) { 30 echo get_class($e), ": ", $e->getMessage(), "\n"; 31 } 32 echo "\n"; 33 echo "socket_get_option "; 34 try { 35 print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE)); 36 } catch (Error $e) { 37 echo get_class($e), ": ", $e->getMessage(), "\n"; 38 } 39 echo "\n"; 40 } 41 echo "\n"; 42} 43 44echo "normal\n"; 45$stream0 = stream_socket_server("udp://0.0.0.0:0", $errno, $errstr, STREAM_SERVER_BIND); 46$sock0 = socket_import_stream($stream0); 47test($stream0, $sock0); 48 49echo "\nunset stream\n"; 50$stream1 = stream_socket_server("udp://0.0.0.0:0", $errno, $errstr, STREAM_SERVER_BIND); 51$sock1 = socket_import_stream($stream1); 52unset($stream1); 53test(null, $sock1); 54 55echo "\nunset socket\n"; 56$stream2 = stream_socket_server("udp://0.0.0.0:0", $errno, $errstr, STREAM_SERVER_BIND); 57$sock2 = socket_import_stream($stream2); 58unset($sock2); 59test($stream2, null); 60 61echo "\nclose stream\n"; 62$stream3 = stream_socket_server("udp://0.0.0.0:0", $errno, $errstr, STREAM_SERVER_BIND); 63$sock3 = socket_import_stream($stream3); 64fclose($stream3); 65test($stream3, $sock3); 66 67echo "\nclose socket\n"; 68$stream4 = stream_socket_server("udp://0.0.0.0:0", $errno, $errstr, STREAM_SERVER_BIND); 69$sock4 = socket_import_stream($stream4); 70socket_close($sock4); 71test($stream4, $sock4); 72?> 73--EXPECTF-- 74normal 75stream_set_blocking 1 76socket_set_block 1 77socket_get_option 2 78 79 80unset stream 81socket_set_block 1 82socket_get_option 2 83 84 85unset socket 86stream_set_blocking 1 87 88 89close stream 90stream_set_blocking TypeError: stream_set_blocking(): supplied resource is not a valid stream resource 91 92socket_set_block 93Warning: socket_set_block(): unable to set blocking mode [10038]: %s in %ssocket_import_stream-4-win.php on line %d 94 95socket_get_option 96Warning: socket_get_option(): Unable to retrieve socket option [10038]: %s in %ssocket_import_stream-4-win.php on line %d 97 98 99 100close socket 101stream_set_blocking TypeError: stream_set_blocking(): supplied resource is not a valid stream resource 102 103socket_set_block Error: socket_set_block(): Argument #1 ($socket) has already been closed 104 105socket_get_option Error: socket_get_option(): Argument #1 ($socket) has already been closed 106