Annotation of embedaddon/php/ext/standard/tests/network/tcp6loop.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Streams Based IPv6 TCP Loopback test
3: --SKIPIF--
4: <?php
5: /* If IPv6 is supported on the platform this will error out with code 111 - Connection refused.
6: If IPv6 is NOT supported, $errno will be set to something else (indicating parse/getaddrinfo error)
7: Note: Might be a good idea to export an IPv6 support indicator (such as AF_INET6 exported by ext/sockets) */
8: @stream_socket_client('tcp://[::1]:0', $errno);
9: if ($errno != 111) die('skip IPv6 not supported.');
10: ?>
11: --FILE--
12: <?php
1.1.1.2 ! misho 13:
! 14: for ($i=0; $i<100; $i++) {
! 15: $port = rand(10000, 65000);
! 16: /* Setup socket server */
! 17: $server = @stream_socket_server("tcp://[::1]:$port");
! 18: if ($server) {
! 19: break;
! 20: }
! 21: }
! 22:
1.1 misho 23: if (!$server) {
24: die('Unable to create AF_INET6 socket [server]');
25: }
26:
27: /* Connect to it */
1.1.1.2 ! misho 28: $client = stream_socket_client("tcp://[::1]:$port");
1.1 misho 29: if (!$client) {
30: die('Unable to create AF_INET6 socket [client]');
31: }
32:
33: /* Accept that connection */
34: $socket = stream_socket_accept($server);
35: if (!$socket) {
36: die('Unable to accept connection');
37: }
38:
39: fwrite($client, "ABCdef123\n");
40:
41: $data = fread($socket, 10);
42: var_dump($data);
43:
44: fclose($client);
45: fclose($socket);
46: fclose($server);
47: ?>
48: --EXPECT--
49: string(10) "ABCdef123
50: "
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>