}
if (getenv('SKIP_ONLINE_TESTS')) die('skip online test');
$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
-$br = socket_bind($s, '0.0.0.0', 3000);
+$br = socket_bind($s, '0.0.0.0', 0);
$so = @socket_set_option($s, IPPROTO_IP, MCAST_JOIN_GROUP, array(
"group" => '224.0.0.23',
"interface" => 'lo',
echo "creating receive socket\n";
$s = socket_create($domain, SOCK_DGRAM, SOL_UDP);
var_dump($s);
-$br = socket_bind($s, '0.0.0.0', 3000);
+$br = socket_bind($s, '0.0.0.0', 0);
+socket_getsockname($s, $unused, $port);
var_dump($br);
$so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array(
));
var_dump($so);
-$r = socket_sendto($sends1, $m = "initial packet", strlen($m), 0, $mcastaddr, 3000);
+$r = socket_sendto($sends1, $m = "initial packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
$i = 0;
"interface" => $interface,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
- $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000);
+ $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", $port);
var_dump($r);
}
if ($i == 2) {
"interface" => $interface,
));
var_dump($so);
- $r = socket_sendto($sends2, $m = "ignored mcast packet (different interface)", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends2, $m = "ignored mcast packet (different interface)", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
- $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
}
if ($i == 3) {
"source" => $sblock,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "ignored packet (blocked source)", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "ignored packet (blocked source)", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
- $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000);
+ $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", $port);
var_dump($r);
}
if ($i == 4) {
"source" => $sblock,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "mcast packet from 127.0.0.1", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "mcast packet from 127.0.0.1", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
}
if ($i == 5) {
"interface" => $interface,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
- $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000);
+ $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", $port);
var_dump($r);
}
if ($i == 6) {
"source" => $sblock,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "mcast packet from 127.0.0.1", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "mcast packet from 127.0.0.1", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
}
if ($i == 7) {
"source" => $sblock,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
- $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", 3000);
+ $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "127.0.0.1", $port);
var_dump($r);
}
if ($i == 8) {
if ($s === false) {
die("skip unable to create socket");
}
-$br = socket_bind($s, '::', 3000);
+$br = socket_bind($s, '::', 0);
+socket_getsockname($s, $unused, $port);
/* On Linux, there is no route ff00::/8 by default on lo, which makes it
* troublesome to send multicast traffic from lo, which we must since
* we're dealing with interface-local traffic... */
if ($so === false) {
die('skip unable to join multicast group on any interface.');
}
-$r = socket_sendto($s, $m = "testing packet", strlen($m), 0, 'ff01::114', 3000);
+$r = socket_sendto($s, $m = "testing packet", strlen($m), 0, 'ff01::114', $port);
if ($r === false) {
die('skip unable to send multicast packet.');
}
echo "creating receive socket\n";
$s = socket_create($domain, SOCK_DGRAM, SOL_UDP) or die("err");
var_dump($s);
-$br = socket_bind($s, '::0', 3000) or die("err");
+$br = socket_bind($s, '::0', 0) or die("err");
var_dump($br);
+socket_getsockname($s, $unused, $port);
$so = socket_set_option($s, $level, MCAST_JOIN_GROUP, array(
"group" => $mcastaddr,
)) or die("err");
var_dump($so);
-$r = socket_sendto($sends1, $m = "testing packet", strlen($m), 0, $mcastaddr, 3000);
+$r = socket_sendto($sends1, $m = "testing packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
checktimeout($s, 500);
$r = socket_recvfrom($s, $str, 2000, 0, $from, $fromPort);
var_dump($r, $str, $from);
$sblock = $from;
-$r = socket_sendto($sends1, $m = "initial packet", strlen($m), 0, $mcastaddr, 3000);
+$r = socket_sendto($sends1, $m = "initial packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
$i = 0;
"interface" => $interface,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
- $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000);
+ $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", $port);
var_dump($r);
}
if ($i == 2) {
"interface" => $interface,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
}
if ($i == 3) {
"source" => $sblock,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "ignored packet (blocked source)", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "ignored packet (blocked source)", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
- $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000);
+ $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", $port);
var_dump($r);
}
if ($i == 4) {
"source" => $sblock,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "mcast packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
}
if ($i == 5) {
"interface" => $interface,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
- $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000);
+ $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", $port);
var_dump($r);
}
if ($i == 6) {
"source" => $sblock,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "mcast packet from desired source", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "mcast packet from desired source", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
}
if ($i == 7) {
"source" => $sblock,
));
var_dump($so);
- $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, 3000);
+ $r = socket_sendto($sends1, $m = "ignored mcast packet", strlen($m), 0, $mcastaddr, $port);
var_dump($r);
- $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", 3000);
+ $r = socket_sendto($sends1, $m = "unicast packet", strlen($m), 0, "::1", $port);
var_dump($r);
}
if ($i == 8) {