PageRenderTime 676ms CodeModel.GetById 462ms app.highlight 4ms RepoModel.GetById 108ms app.codeStats 0ms

/hphp/test/zend/bad/ext/sockets/tests/socket_import_stream-4.php

http://github.com/facebook/hiphop-php
PHP | 49 lines | 42 code | 7 blank | 0 comment | 2 complexity | 4a5eeb2106aa9f373260264612ac01bc MD5 | raw file
 1<?php
 2
 3function test($stream, $sock) {
 4	if ($stream !== null) {
 5		echo "stream_set_blocking ";
 6		print_r(stream_set_blocking($stream, 0));
 7		echo "\n";
 8	}
 9	if ($sock !== null) {
10		echo "socket_set_block ";
11		print_r(socket_set_block($sock));
12		echo "\n";
13		echo "socket_get_option ";
14		print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE));
15		echo "\n";
16	}
17	echo "\n";
18}
19
20echo "normal\n";
21$stream0 = stream_socket_server("udp://0.0.0.0:58380", $errno, $errstr, STREAM_SERVER_BIND);
22$sock0 = socket_import_stream($stream0);
23test($stream0, $sock0);
24
25echo "\nunset stream\n";
26$stream1 = stream_socket_server("udp://0.0.0.0:58381", $errno, $errstr, STREAM_SERVER_BIND);
27$sock1 = socket_import_stream($stream1);
28unset($stream1);
29test(null, $sock1);
30
31echo "\nunset socket\n";
32$stream2 = stream_socket_server("udp://0.0.0.0:58382", $errno, $errstr, STREAM_SERVER_BIND);
33$sock2 = socket_import_stream($stream2);
34unset($sock2);
35test($stream2, null);
36
37echo "\nclose stream\n";
38$stream3 = stream_socket_server("udp://0.0.0.0:58383", $errno, $errstr, STREAM_SERVER_BIND);
39$sock3 = socket_import_stream($stream3);
40fclose($stream3);
41test($stream3, $sock3);
42
43echo "\nclose socket\n";
44$stream4 = stream_socket_server("udp://0.0.0.0:58384", $errno, $errstr, STREAM_SERVER_BIND);
45$sock4 = socket_import_stream($stream4);
46socket_close($sock4);
47test($stream4, $sock4);
48
49echo "Done.\n";