1--TEST--
2Multicast support: IPv4 send options
3--SKIPIF--
4<?php
5if (!extension_loaded('sockets')) {
6    die('skip sockets extension not available.');
7}
8$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) or die("err");
9if (socket_set_option($s, IPPROTO_IP, IP_MULTICAST_IF, 1) === false) {
10    die("skip interface 1 either doesn't exist or has no ipv4 address");
11}
12--FILE--
13<?php
14$domain = AF_INET;
15$level = IPPROTO_IP;
16$s = socket_create($domain, SOCK_DGRAM, SOL_UDP) or die("err");
17
18echo "Setting IP_MULTICAST_TTL\n";
19$r = socket_set_option($s, $level, IP_MULTICAST_TTL, 9);
20var_dump($r);
21$r = socket_get_option($s, $level, IP_MULTICAST_TTL);
22var_dump($r);
23echo "\n";
24
25echo "Setting IP_MULTICAST_LOOP\n";
26$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 0);
27var_dump($r);
28$r = socket_get_option($s, $level, IP_MULTICAST_LOOP);
29var_dump($r);
30$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 1);
31var_dump($r);
32$r = socket_get_option($s, $level, IP_MULTICAST_LOOP);
33var_dump($r);
34echo "\n";
35
36echo "Setting IP_MULTICAST_IF\n";
37echo "interface 0:\n";
38$r = socket_set_option($s, $level, IP_MULTICAST_IF, 0);
39var_dump($r);
40$r = socket_get_option($s, $level, IP_MULTICAST_IF);
41var_dump($r);
42echo "interface 1:\n";
43$r = socket_set_option($s, $level, IP_MULTICAST_IF, 1);
44var_dump($r);
45$r = socket_get_option($s, $level, IP_MULTICAST_IF);
46var_dump($r);
47echo "\n";
48?>
49--EXPECT--
50Setting IP_MULTICAST_TTL
51bool(true)
52int(9)
53
54Setting IP_MULTICAST_LOOP
55bool(true)
56int(0)
57bool(true)
58int(1)
59
60Setting IP_MULTICAST_IF
61interface 0:
62bool(true)
63int(0)
64interface 1:
65bool(true)
66int(1)
67