1--TEST--
2Streams 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
13	/* Setup socket server */
14	$server = stream_socket_server('tcp://[::1]:31337');
15	if (!$server) {
16		die('Unable to create AF_INET6 socket [server]');
17	}
18
19	/* Connect to it */
20	$client = stream_socket_client('tcp://[::1]:31337');
21	if (!$client) {
22		die('Unable to create AF_INET6 socket [client]');
23	}
24
25	/* Accept that connection */
26	$socket = stream_socket_accept($server);
27	if (!$socket) {
28		die('Unable to accept connection');
29	}
30
31	fwrite($client, "ABCdef123\n");
32
33	$data = fread($socket, 10);
34	var_dump($data);
35
36	fclose($client);
37	fclose($socket);
38	fclose($server);
39?>
40--EXPECT--
41string(10) "ABCdef123
42"
43