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--EXPECT--
49Setting IP_MULTICAST_TTL
50bool(true)
51int(9)
52
53Setting IP_MULTICAST_LOOP
54bool(true)
55int(0)
56bool(true)
57int(1)
58
59Setting IP_MULTICAST_IF
60interface 0:
61bool(true)
62int(0)
63interface 1:
64bool(true)
65int(1)
66