Skip to content
Browse files

Bug #63000: MCAST_JOIN_GROUP on OSX is broken

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.

For reference, this was also done in VLC:

  • Loading branch information...
1 parent ee172ce commit 188c124a57a27e3d6baf786608a45d713d4595f6 @lstrojny lstrojny committed Sep 19, 2012
Showing with 28 additions and 3 deletions.
  1. +3 −1 NEWS
  2. +3 −2 ext/sockets/multicast.h
  3. +22 −0 ext/sockets/tests/bug63000.phpt
@@ -247,7 +247,9 @@ PHP NEWS
- Sockets:
. Fixed bug #62025 (__ss_family was changed on AIX 5.3). (Felipe)
+ . Fixed bug #63000 (MCAST_JOIN_GROUP on OSX is broken, merge of PR 185 by
+ Igor Wiedler). (Lars)
- SPL:
. Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to
dot files). (Laruence)
5 ext/sockets/multicast.h
@@ -19,11 +19,12 @@
/* $Id$ */
#if defined(MCAST_JOIN_GROUP) && \
- (!defined(PHP_WIN32) || (_WIN32_WINNT >= 0x600 && SOCKETS_ENABLE_VISTA_API))
+ (!defined(PHP_WIN32) || (_WIN32_WINNT >= 0x600 && SOCKETS_ENABLE_VISTA_API)) && \
+ !defined(__APPLE__)
smalyshev added a note Sep 20, 2012

I'm not sure this is right - this means that in any Apple system this would not be defined. What if the implementation is fixed? I think the scope should be a bit more limited than "all apple systems".

cataphract added a note Sep 20, 2012

@smalyshev When it happens, we can limit it to certain versions. Meanwhile, don't get your hopes high on Apple fixing this soon. Last time I checked (an year ago) they were still using a 2001 kame network stack...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
#define RFC3678_API 1
/* has block/unblock and source membership, in this case for both IPv4 and IPv6 */
#define HAS_MCAST_EXT 1
+#elif defined(IP_ADD_SOURCE_MEMBERSHIP) && !defined(__APPLE__)
cataphract added a note Sep 20, 2012

I don't think this change is correct. The bug report only mentions Mac OS X having the RFC3678 constants, but not the functionality. It says nothing about this part of the older API.

I also think in the end it doesn't make any difference because OS X is so poor in this matter that it doesn't even have IP_ADD_SOURCE_MEMBERSHIP (and related constants) so the first condition already fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
/* has block/unblock and source membership, but only for IPv4 */
#define HAS_MCAST_EXT 1
22 ext/sockets/tests/bug63000.phpt
@@ -0,0 +1,22 @@
+Bug #63000: Multicast on OSX
+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, '', 31057);
+$so = socket_set_option($socket, IPPROTO_IP, MCAST_JOIN_GROUP, array(
+ "group" => '',
+ "interface" => 0,

0 comments on commit 188c124

Please sign in to comment.
Something went wrong with that request. Please try again.