1--TEST--
2socket_export_stream: Test with multicasting
3--EXTENSIONS--
4sockets
5--SKIPIF--
6<?php
7
8$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
9socket_bind($s, '0.0.0.0', 0);
10$so = @socket_set_option($s, IPPROTO_IP, MCAST_JOIN_GROUP, array(
11    "group"	=> '224.0.0.23',
12    "interface" => "lo",
13));
14if ($so === false)
15    die("SKIP joining group 224.0.0.23 on interface lo failed");
16--FILE--
17<?php
18
19$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
20socket_bind($sock, '0.0.0.0', 0);
21socket_getsockname($sock, $unused, $port);
22$stream = socket_export_stream($sock);
23var_dump($stream);
24$so = socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array(
25    "group"	=> '224.0.0.23',
26    "interface" => "lo",
27));
28var_dump($so);
29
30$sendsock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
31var_dump($sendsock);
32$br = socket_bind($sendsock, '127.0.0.1');
33$so = socket_sendto($sendsock, $m = "my message", strlen($m), 0, "224.0.0.23", $port);
34var_dump($so);
35
36stream_set_blocking($stream, 0);
37var_dump(fread($stream, strlen($m)));
38echo "Done.\n";
39?>
40--EXPECTF--
41resource(%d) of type (stream)
42bool(true)
43object(Socket)#%d (0) {
44}
45int(10)
46string(10) "my message"
47Done.
48