mirror of
https://github.com/php/php-src.git
synced 2024-09-23 19:07:26 +00:00
f1d7e3ca0b
This patch adds missing newlines, trims multiple redundant final newlines into a single one, and trims redundant leading newlines in all *.phpt sections. According to POSIX, a line is a sequence of zero or more non-' <newline>' characters plus a terminating '<newline>' character. [1] Files should normally have at least one final newline character. C89 [2] and later standards [3] mention a final newline: "A source file that is not empty shall end in a new-line character, which shall not be immediately preceded by a backslash character." Although it is not mandatory for all files to have a final newline fixed, a more consistent and homogeneous approach brings less of commit differences issues and a better development experience in certain text editors and IDEs. [1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206 [2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2 [3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
108 lines
2.5 KiB
PHP
108 lines
2.5 KiB
PHP
--TEST--
|
|
socket_export_stream: effects of closing
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('sockets')) {
|
|
die('SKIP sockets extension not available.');
|
|
}
|
|
if(substr(PHP_OS, 0, 3) != 'WIN' ) {
|
|
die("skip Not Valid for Linux");
|
|
}
|
|
--FILE--
|
|
<?php
|
|
|
|
function test($stream, $sock) {
|
|
if ($stream !== null) {
|
|
echo "stream_set_blocking ";
|
|
print_r(stream_set_blocking($stream, 0));
|
|
echo "\n";
|
|
}
|
|
if ($sock !== null) {
|
|
echo "socket_set_block ";
|
|
print_r(socket_set_block($sock));
|
|
echo "\n";
|
|
echo "socket_get_option ";
|
|
print_r(socket_get_option($sock, SOL_SOCKET, SO_TYPE));
|
|
echo "\n";
|
|
}
|
|
echo "\n";
|
|
}
|
|
|
|
echo "normal\n";
|
|
$sock0 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
|
socket_bind($sock0, '0.0.0.0', 58380);
|
|
$stream0 = socket_export_stream($sock0);
|
|
test($stream0, $sock0);
|
|
|
|
echo "\nunset stream\n";
|
|
$sock1 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
|
socket_bind($sock1, '0.0.0.0', 58381);
|
|
$stream1 = socket_export_stream($sock1);
|
|
unset($stream1);
|
|
test(null, $sock1);
|
|
|
|
echo "\nunset socket\n";
|
|
$sock2 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
|
socket_bind($sock2, '0.0.0.0', 58382);
|
|
$stream2 = socket_export_stream($sock2);
|
|
unset($sock2);
|
|
test($stream2, null);
|
|
|
|
echo "\nclose stream\n";
|
|
$sock3 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
|
socket_bind($sock3, '0.0.0.0', 58383);
|
|
$stream3 = socket_export_stream($sock3);
|
|
fclose($stream3);
|
|
test($stream3, $sock3);
|
|
|
|
echo "\nclose socket\n";
|
|
$sock4 = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
|
|
socket_bind($sock4, '0.0.0.0', 58484);
|
|
$stream4 = socket_export_stream($sock4);
|
|
socket_close($sock4);
|
|
test($stream4, $sock4);
|
|
|
|
echo "Done.\n";
|
|
--EXPECTF--
|
|
normal
|
|
stream_set_blocking 1
|
|
socket_set_block 1
|
|
socket_get_option 2
|
|
|
|
|
|
unset stream
|
|
socket_set_block 1
|
|
socket_get_option 2
|
|
|
|
|
|
unset socket
|
|
stream_set_blocking 1
|
|
|
|
|
|
close stream
|
|
stream_set_blocking
|
|
Warning: stream_set_blocking(): supplied resource is not a valid stream resource in %s on line %d
|
|
|
|
socket_set_block
|
|
Warning: socket_set_block(): unable to set blocking mode [%d]: An operation was attempted on something that is not a socket.
|
|
in %s on line %d
|
|
|
|
socket_get_option
|
|
Warning: socket_get_option(): unable to retrieve socket option [%d]: An operation was attempted on something that is not a socket.
|
|
in %s on line %d
|
|
|
|
|
|
|
|
close socket
|
|
stream_set_blocking
|
|
Warning: stream_set_blocking(): supplied resource is not a valid stream resource in %s on line %d
|
|
|
|
socket_set_block
|
|
Warning: socket_set_block(): supplied resource is not a valid Socket resource in %s on line %d
|
|
|
|
socket_get_option
|
|
Warning: socket_get_option(): supplied resource is not a valid Socket resource in %s on line %d
|
|
|
|
|
|
Done.
|