1--TEST--
2Multicast support: IPv4 send options
3--EXTENSIONS--
4sockets
5--SKIPIF--
6<?php
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?>
13--FILE--
14<?php
15$domain = AF_INET;
16$level = IPPROTO_IP;
17$s = socket_create($domain, SOCK_DGRAM, SOL_UDP) or die("err");
18
19echo "Setting IP_MULTICAST_TTL\n";
20$r = socket_set_option($s, $level, IP_MULTICAST_TTL, 9);
21var_dump($r);
22$r = socket_get_option($s, $level, IP_MULTICAST_TTL);
23var_dump($r);
24echo "\n";
25
26echo "Setting IP_MULTICAST_LOOP\n";
27$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 0);
28var_dump($r);
29$r = socket_get_option($s, $level, IP_MULTICAST_LOOP);
30var_dump($r);
31$r = socket_set_option($s, $level, IP_MULTICAST_LOOP, 1);
32var_dump($r);
33$r = socket_get_option($s, $level, IP_MULTICAST_LOOP);
34var_dump($r);
35echo "\n";
36
37echo "Setting IP_MULTICAST_IF\n";
38echo "interface 0:\n";
39$r = socket_set_option($s, $level, IP_MULTICAST_IF, 0);
40var_dump($r);
41$r = socket_get_option($s, $level, IP_MULTICAST_IF);
42var_dump($r);
43echo "interface 1:\n";
44$r = socket_set_option($s, $level, IP_MULTICAST_IF, 1);
45var_dump($r);
46$r = socket_get_option($s, $level, IP_MULTICAST_IF);
47var_dump($r);
48echo "\n";
49?>
50--EXPECT--
51Setting IP_MULTICAST_TTL
52bool(true)
53int(9)
54
55Setting IP_MULTICAST_LOOP
56bool(true)
57int(0)
58bool(true)
59int(1)
60
61Setting IP_MULTICAST_IF
62interface 0:
63bool(true)
64int(0)
65interface 1:
66bool(true)
67int(1)
68