Annotation of embedaddon/php/ext/standard/tests/network/udp6loop.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Streams Based IPv6 UDP Loopback test
                      3: --SKIPIF--
                      4: <?php # vim:ft=php:
                      5:        /* If IPv6 is supported on the platform this will error out with code 111 -
                      6:         * Connection refused.  If IPv6 is NOT supported, $errno will be set to
                      7:         * something else (indicating parse/getaddrinfo error)
                      8:         * Note: Might be a good idea to export an IPv6 support indicator
                      9:         * (such as AF_INET6 exported by ext/sockets), however, since we
                     10:         * cannot tell for sure if IPv6 works until we probe it at run time,
                     11:         * this isn't really practical.
                     12:         */
                     13: 
                     14:        @stream_socket_client('tcp://[::1]:0', $errno);
                     15:        if ($errno != 111) die('skip IPv6 not supported.');
                     16: ?>
                     17: --FILE--
                     18: <?php
1.1.1.2 ! misho      19: 
        !            20:   for ($i=0; $i<100; $i++) {
        !            21:     $port = rand(10000, 65000);
        !            22:     /* Setup socket server */
        !            23:     $server = @stream_socket_server("udp://[::1]:$port", $errno, $errstr, STREAM_SERVER_BIND);
        !            24:     if ($server) {
        !            25:       break;
        !            26:     }
        !            27:   }
        !            28: 
1.1       misho      29:        if (!$server) {
                     30:                die('Unable to create AF_INET6 socket [server]');
                     31:        }
                     32: 
                     33:        /* Connect to it */
1.1.1.2 ! misho      34:        $client = stream_socket_client("udp://[::1]:$port");
1.1       misho      35:        if (!$client) {
                     36:                die('Unable to create AF_INET6 socket [client]');
                     37:        }
                     38: 
                     39:        fwrite($client, "ABCdef123\n");
                     40: 
                     41:        $data = fread($server, 10);
                     42:        var_dump($data);
                     43: 
                     44:        fclose($client);
                     45:        fclose($server);
                     46: ?>
                     47: --EXPECT--
                     48: string(10) "ABCdef123
                     49: "

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>