1--TEST-- 2socket_import_stream: effects of closing 3--SKIPIF-- 4<?php 5if (!extension_loaded('sockets')) { 6 die('SKIP sockets extension not available.'); 7} 8if(substr(PHP_OS, 0, 3) == 'WIN' ) { 9 die("skip Not Valid for Windows"); 10} 11--FILE-- 12<?php 13 14function 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 31echo "normal\n"; 32$stream0 = stream_socket_server("udp://0.0.0.0:58387", $errno, $errstr, STREAM_SERVER_BIND); 33$sock0 = socket_import_stream($stream0); 34test($stream0, $sock0); 35 36echo "\nunset stream\n"; 37$stream1 = stream_socket_server("udp://0.0.0.0:58388", $errno, $errstr, STREAM_SERVER_BIND); 38$sock1 = socket_import_stream($stream1); 39unset($stream1); 40test(null, $sock1); 41 42echo "\nunset socket\n"; 43$stream2 = stream_socket_server("udp://0.0.0.0:58389", $errno, $errstr, STREAM_SERVER_BIND); 44$sock2 = socket_import_stream($stream2); 45unset($sock2); 46test($stream2, null); 47 48echo "\nclose stream\n"; 49$stream3 = stream_socket_server("udp://0.0.0.0:58390", $errno, $errstr, STREAM_SERVER_BIND); 50$sock3 = socket_import_stream($stream3); 51fclose($stream3); 52test($stream3, $sock3); 53 54echo "\nclose socket\n"; 55$stream4 = stream_socket_server("udp://0.0.0.0:58391", $errno, $errstr, STREAM_SERVER_BIND); 56$sock4 = socket_import_stream($stream4); 57socket_close($sock4); 58test($stream4, $sock4); 59 60echo "Done.\n"; 61--EXPECTF-- 62normal 63stream_set_blocking 1 64socket_set_block 1 65socket_get_option 2 66 67 68unset stream 69socket_set_block 1 70socket_get_option 2 71 72 73unset socket 74stream_set_blocking 1 75 76 77close stream 78stream_set_blocking 79Warning: stream_set_blocking(): supplied resource is not a valid stream resource in %s on line %d 80 81socket_set_block 82Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d 83 84socket_get_option 85Warning: socket_get_option(): unable to retrieve socket option [%d]: %s in %s on line %d 86 87 88 89close socket 90stream_set_blocking 91Warning: stream_set_blocking(): supplied resource is not a valid stream resource in %s on line %d 92 93socket_set_block 94Warning: socket_set_block(): supplied resource is not a valid Socket resource in %s on line %d 95 96socket_get_option 97Warning: socket_get_option(): supplied resource is not a valid Socket resource in %s on line %d 98 99 100Done. 101