1--TEST-- 2socket_export_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 Windows"); 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$sock0 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 46socket_bind($sock0, '0.0.0.0'); 47$stream0 = socket_export_stream($sock0); 48test($stream0, $sock0); 49 50echo "\nunset stream\n"; 51$sock1 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 52socket_bind($sock1, '0.0.0.0'); 53$stream1 = socket_export_stream($sock1); 54unset($stream1); 55test(null, $sock1); 56 57echo "\nunset socket\n"; 58$sock2 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 59socket_bind($sock2, '0.0.0.0'); 60$stream2 = socket_export_stream($sock2); 61unset($sock2); 62test($stream2, null); 63 64echo "\nclose stream\n"; 65$sock3 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 66socket_bind($sock3, '0.0.0.0'); 67$stream3 = socket_export_stream($sock3); 68fclose($stream3); 69test($stream3, $sock3); 70 71echo "\nclose socket\n"; 72$sock4 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); 73socket_bind($sock4, '0.0.0.0'); 74$stream4 = socket_export_stream($sock4); 75socket_close($sock4); 76test($stream4, $sock4); 77 78echo "Done.\n"; 79?> 80--EXPECTF-- 81normal 82stream_set_blocking 1 83socket_set_block 1 84socket_get_option 2 85 86 87unset stream 88socket_set_block 1 89socket_get_option 2 90 91 92unset socket 93stream_set_blocking 1 94 95 96close stream 97stream_set_blocking TypeError: stream_set_blocking(): supplied resource is not a valid stream resource 98 99socket_set_block 100Warning: socket_set_block(): unable to set blocking mode [%d]: %s in %s on line %d 101 102socket_get_option 103Warning: socket_get_option(): Unable to retrieve socket option [%d]: %s in %s on line %d 104 105 106 107close socket 108stream_set_blocking TypeError: stream_set_blocking(): supplied resource is not a valid stream resource 109 110socket_set_block Error: socket_set_block(): Argument #1 ($socket) has already been closed 111 112socket_get_option Error: socket_get_option(): Argument #1 ($socket) has already been closed 113 114 115Done. 116