1--TEST--
2socket_import_stream: Test with multicasting
3--EXTENSIONS--
4sockets
5--SKIPIF--
6<?php
7
8$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
9$br = @socket_bind($s, '0.0.0.0', 58379);
10if ($br === false)
11    die("SKIP IPv4/port 58379 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?>
19--FILE--
20<?php
21
22$stream = stream_socket_server("udp://0.0.0.0:58379", $errno, $errstr, STREAM_SERVER_BIND);
23$sock = socket_import_stream($stream);
24var_dump($sock);
25$so = socket_set_option($sock, IPPROTO_IP, MCAST_JOIN_GROUP, array(
26    "group"	=> '224.0.0.23',
27    "interface" => "lo",
28));
29var_dump($so);
30
31$sendsock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
32var_dump($sendsock);
33$br = socket_bind($sendsock, '127.0.0.1');
34$so = socket_sendto($sendsock, $m = "my message", strlen($m), 0, "224.0.0.23", 58379);
35var_dump($so);
36
37stream_set_blocking($stream, 0);
38var_dump(fread($stream, strlen($m)));
39echo "Done.\n";
40?>
41--EXPECTF--
42object(Socket)#%d (0) {
43}
44bool(true)
45object(Socket)#%d (0) {
46}
47int(10)
48string(10) "my message"
49Done.
50