MCAST_JOIN_GROUP on OSX is broken
| Bug #63000 | MCAST_JOIN_GROUP on OSX is broken | ||||
|---|---|---|---|---|---|
| Submitted: | 2012-09-02 21:38 UTC | Modified: | 2012-09-19 20:36 UTC | ||
| From: | igor at wiedler dot ch | Assigned: | |||
| Status: | Closed | Package: | Sockets related | ||
| PHP Version: | 5.4.6 | OS: | Mac OSX 10.7, 10.8 | ||
| Private report: | No | CVE-ID: | None | ||
[2012-09-02 21:38 UTC] igor at wiedler dot ch
Description:
------------
The multicast support in PHP 5.4 makes use of MCAST_JOIN_GROUP if it is present.
The problem is that OSX 10.7 added the constant, but did not correctly implement
the feature. This causes the setsockopt call to fail.
The solution to the problem is to not use MCAST_JOIN_GROUP on OSX.
Test script:
---------------
<?php
if (!extension_loaded('sockets')) {
die('skip sockets extension not available.');
}
if (PHP_OS !== 'Darwin') {
die('is not OSX.');
}
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
socket_bind($socket, '0.0.0.0', 31057);
$so = socket_set_option($socket, IPPROTO_IP, MCAST_JOIN_GROUP, array(
"group" => '224.0.0.251',
"interface" => 0,
));
var_dump($so);
Expected result:
----------------
bool(true)
Actual result:
--------------
PHP Warning: socket_set_option(): unable to set socket option [22]: Invalid
argument in /Users/igor/code/react-mdns-userland/src/React/Mdns/Client.php on
line 27
PHP Stack trace:
PHP 1. {main}() /Users/igor/code/react-mdns-userland/examples/client.php:0
PHP 2. React\Mdns\Client->query() /Users/igor/code/react-mdns-
userland/examples/client.php:10
PHP 3. socket_set_option() /Users/igor/code/react-mdns-
userland/src/React/Mdns/Client.php:27
bool(false)
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2012-09-03 02:47 UTC] reeze dot xia at gmail dot com
[2012-09-03 02:53 UTC] reeze dot xia at gmail dot com
[2012-09-03 05:42 UTC] laruence@php.net
[2012-09-03 20:08 UTC] cataphract@php.net
[2012-09-04 00:09 UTC] igor at wiedler dot ch
[2012-09-19 20:36 UTC] lstrojny@php.net