Annotation of embedaddon/php/ext/sockets/tests/mcast_ipv4_send_error.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Multicast support: IPv4 send options with unusual values
        !             3: --SKIPIF--
        !             4: <?php
        !             5: if (!extension_loaded('sockets')) {
        !             6:     die('skip sockets extension not available.');
        !             7: }
        !             8: if (socket_set_option($s, $level, IP_MULTICAST_IF, 1) === false) {
        !             9:        die("skip interface 1 either doesn't exist or has no ipv4 address");
        !            10: }
        !            11: --FILE--
        !            12: <?php
        !            13: $domain = AF_INET;
        !            14: $level = IPPROTO_IP;
        !            15: $s = socket_create($domain, SOCK_DGRAM, SOL_UDP) or die("err");
        !            16: 
        !            17: echo "Setting IP_MULTICAST_LOOP with 256\n";
        !            18: //if we had a simple cast to unsigned char, this would be the same as 0
        !            19: $r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 256);
        !            20: var_dump($r);
        !            21: $r = socket_get_option($s, $level, IP_MULTICAST_LOOP);
        !            22: var_dump($r);
        !            23: echo "\n";
        !            24: 
        !            25: echo "Setting IP_MULTICAST_LOOP with false\n";
        !            26: //should convert to (unsigned char)0
        !            27: $r = socket_set_option($s, $level, IP_MULTICAST_LOOP, false);
        !            28: var_dump($r);
        !            29: $r = socket_get_option($s, $level, IP_MULTICAST_LOOP);
        !            30: var_dump($r);
        !            31: echo "\n";
        !            32: 
        !            33: echo "Setting IP_MULTICAST_TTL with 256\n";
        !            34: //if we had a simple cast to unsigned char, this would be the same as 0
        !            35: $r = socket_set_option($s, $level, IP_MULTICAST_TTL, 256);
        !            36: var_dump($r);
        !            37: $r = socket_get_option($s, $level, IP_MULTICAST_TTL);
        !            38: var_dump($r);
        !            39: echo "\n";
        !            40: 
        !            41: echo "Setting IP_MULTICAST_TTL with \"254\"\n";
        !            42: $r = socket_set_option($s, $level, IP_MULTICAST_TTL, "254");
        !            43: var_dump($r);
        !            44: $r = socket_get_option($s, $level, IP_MULTICAST_TTL);
        !            45: var_dump($r);
        !            46: echo "\n";
        !            47: 
        !            48: echo "Setting IP_MULTICAST_TTL with -1\n";
        !            49: //should give error, not be the same as 255
        !            50: $r = socket_set_option($s, $level, IP_MULTICAST_TTL, -1);
        !            51: var_dump($r);
        !            52: $r = socket_get_option($s, $level, IP_MULTICAST_TTL);
        !            53: var_dump($r);
        !            54: echo "\n";
        !            55: 
        !            56: --EXPECTF--
        !            57: Setting IP_MULTICAST_LOOP with 256
        !            58: bool(true)
        !            59: int(1)
        !            60: 
        !            61: Setting IP_MULTICAST_LOOP with false
        !            62: bool(true)
        !            63: int(0)
        !            64: 
        !            65: Setting IP_MULTICAST_TTL with 256
        !            66: 
        !            67: Warning: socket_set_option(): Expected a value between 0 and 255 in %s on line %d
        !            68: bool(false)
        !            69: int(1)
        !            70: 
        !            71: Setting IP_MULTICAST_TTL with "254"
        !            72: bool(true)
        !            73: int(254)
        !            74: 
        !            75: Setting IP_MULTICAST_TTL with -1
        !            76: 
        !            77: Warning: socket_set_option(): Expected a value between 0 and 255 in %s on line %d
        !            78: bool(false)
        !            79: int(254)

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