php-src/ext/standard/tests/network/tcp6loop.phpt
ptarjan ecbe4af0de fix many parallel test issues
While running these on HHVM I've run into a lot of parallelism issues.
I'm backporting all the fixes I had to do in
https://github.com/facebook/hiphop-php/blob/master/hphp/tools/import_zend_test.py#L650
to php core.

Most of these changes were just filenames that were shared between
tests, but I did more surgery on the fixed ports. I can apreciate port
31337 as much as the next nerd, but random ports are better for tests.
2013-09-26 00:30:23 -07:00

51 lines
1.2 KiB
PHP

--TEST--
Streams Based IPv6 TCP Loopback test
--SKIPIF--
<?php
/* If IPv6 is supported on the platform this will error out with code 111 - Connection refused.
If IPv6 is NOT supported, $errno will be set to something else (indicating parse/getaddrinfo error)
Note: Might be a good idea to export an IPv6 support indicator (such as AF_INET6 exported by ext/sockets) */
@stream_socket_client('tcp://[::1]:0', $errno);
if ($errno != 111) die('skip IPv6 not supported.');
?>
--FILE--
<?php
for ($i=0; $i<100; $i++) {
$port = rand(10000, 65000);
/* Setup socket server */
$server = @stream_socket_server("tcp://[::1]:$port");
if ($server) {
break;
}
}
if (!$server) {
die('Unable to create AF_INET6 socket [server]');
}
/* Connect to it */
$client = stream_socket_client("tcp://[::1]:$port");
if (!$client) {
die('Unable to create AF_INET6 socket [client]');
}
/* Accept that connection */
$socket = stream_socket_accept($server);
if (!$socket) {
die('Unable to accept connection');
}
fwrite($client, "ABCdef123\n");
$data = fread($socket, 10);
var_dump($data);
fclose($client);
fclose($socket);
fclose($server);
?>
--EXPECT--
string(10) "ABCdef123
"