1--TEST--
2socket_import_stream: Test with multicasting
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);
9$br = socket_bind($s, '0.0.0.0', 58381);
10if ($br === false)
11	die("SKIP IPv4/port 58381 not available");
12$so = socket_set_option($s, IPPROTO_IP, MCAST_JOIN_GROUP, array(
13	"group"	=> '224.0.0.23',
14	"interface" => "lo",
15));
16if ($so === false)
17	die("SKIP joining group 224.0.0.23 on interface lo failed");
18--FILE--
19<?php
20
21$stream = stream_socket_server("udp://0.0.0.0:58381", $errno, $errstr, STREAM_SERVER_BIND);
22$sock = socket_import_stream($stream);
23var_dump($sock);
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", 58381);
34var_dump($so);
35
36stream_set_blocking($stream, 0);
37var_dump(fread($stream, strlen($m)));
38echo "Done.\n";
39--EXPECTF--
40resource(%d) of type (Socket)
41bool(true)
42resource(%d) of type (Socket)
43int(10)
44string(10) "my message"
45Done.
46