Skip to content

Commit 188c124

Browse files
committed
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: * http://trac.videolan.org/vlc/ticket/6104#comment:19
1 parent ee172ce commit 188c124

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

NEWS

+3-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,9 @@ PHP NEWS
247247

248248
- Sockets:
249249
. Fixed bug #62025 (__ss_family was changed on AIX 5.3). (Felipe)
250-
250+
. Fixed bug #63000 (MCAST_JOIN_GROUP on OSX is broken, merge of PR 185 by
251+
Igor Wiedler). (Lars)
252+
251253
- SPL:
252254
. Fixed bug #62433 (Inconsistent behavior of RecursiveDirectoryIterator to
253255
dot files). (Laruence)

ext/sockets/multicast.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
/* $Id$ */
2020

2121
#if defined(MCAST_JOIN_GROUP) && \
22-
(!defined(PHP_WIN32) || (_WIN32_WINNT >= 0x600 && SOCKETS_ENABLE_VISTA_API))
22+
(!defined(PHP_WIN32) || (_WIN32_WINNT >= 0x600 && SOCKETS_ENABLE_VISTA_API)) && \
23+
!defined(__APPLE__)
2324
#define RFC3678_API 1
2425
/* has block/unblock and source membership, in this case for both IPv4 and IPv6 */
2526
#define HAS_MCAST_EXT 1
26-
#elif defined(IP_ADD_SOURCE_MEMBERSHIP)
27+
#elif defined(IP_ADD_SOURCE_MEMBERSHIP) && !defined(__APPLE__)
2728
/* has block/unblock and source membership, but only for IPv4 */
2829
#define HAS_MCAST_EXT 1
2930
#endif

ext/sockets/tests/bug63000.phpt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #63000: Multicast on OSX
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('sockets')) {
6+
die('skip sockets extension not available.');
7+
}
8+
if (PHP_OS !== 'Darwin') {
9+
die('is not OSX.');
10+
}
11+
--FILE--
12+
<?php
13+
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
14+
socket_bind($socket, '0.0.0.0', 31057);
15+
16+
$so = socket_set_option($socket, IPPROTO_IP, MCAST_JOIN_GROUP, array(
17+
"group" => '224.0.0.251',
18+
"interface" => 0,
19+
));
20+
var_dump($so);
21+
--EXPECTF--
22+
bool(true)

0 commit comments

Comments
 (0)