1--TEST--
2Multicast support: IPv4 send options
3--SKIPIF--
4<?php
5if (!extension_loaded('sockets')) {
6    die('skip sockets extension not available.');
7}
8if (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
17echo "Setting IP_MULTICAST_TTL\n";
18$r = socket_set_option($s, $level, IP_MULTICAST_TTL, 9);
19var_dump($r);
20$r = socket_get_option($s, $level, IP_MULTICAST_TTL);
21var_dump($r);
22echo "\n";
23
24echo "Setting IP_MULTICAST_LOOP\n";
25$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 0);
26var_dump($r);
27$r = socket_get_option($s, $level, IP_MULTICAST_LOOP);
28var_dump($r);
29$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 1);
30var_dump($r);
31$r = socket_get_option($s, $level, IP_MULTICAST_LOOP);
32var_dump($r);
33echo "\n";
34
35echo "Setting IP_MULTICAST_IF\n";
36echo "interface 0:\n";
37$r = socket_set_option($s, $level, IP_MULTICAST_IF, 0);
38var_dump($r);
39$r = socket_get_option($s, $level, IP_MULTICAST_IF);
40var_dump($r);
41echo "interface 1:\n";
42$r = socket_set_option($s, $level, IP_MULTICAST_IF, 1);
43var_dump($r);
44$r = socket_get_option($s, $level, IP_MULTICAST_IF);
45var_dump($r);
46echo "\n";
47
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