|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65597 Can't use sockets with MacPorts
Submitted: 2013-08-30 21:00 UTC Modified: 2013-09-08 11:53 UTC
From: miken32 at gmail dot com Assigned: osmanov (profile)
Status: Closed Package: event (PECL)
PHP Version: 5.4.19 OS: OS X 10.7.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: miken32 at gmail dot com
New email:
PHP Version: OS:


 [2013-08-30 21:00 UTC] miken32 at gmail dot com
I installed PHP and the sockets extension via MacPorts, and built this extension 
manually without any errors. But I was unable to use sockets, only stream 

Some digging through the code turned up a check in common.h for HAVE_SOCKETS or 
COMPILE_DL_SOCKETS which were both undefined at compile time. I don't know enough 
about C programming to say much, but the MacPorts folks suggested that your code 
could be changed to check for the presence of the sockets extension another way.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-04 15:43 UTC]
It looks like you have to install a "development package". I'm not an OS X
user, so don't know exactly the name of the package.  Linux distributions often
call it something like "php-dev", "php5-dev", "php-devel" etc.

I guess it had merely been compiled without sockets support as the latter is not 
required currently.

Unfortunately, there is no reliable cross-platform way to detect whether
sockets ext. is present. At least I don't know such way. Both compile-time and
run-time checks have their drawbacks. Just try to install development files of 

Let me know how it will go.
 [2013-09-04 16:12 UTC] miken32 at gmail dot com
That's what I figured was the case. There is no development package in MacPorts, 
it looks like all header files, phpize, etc. are installed with the normal 
package. I'm not sure that it would be able to help in this case anyway, where 
the sockets extension is built separately and loaded dynamically.
 [2013-09-06 17:19 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: osmanov
 [2013-09-06 17:19 UTC]
Sorry, for some reason I don't receive E-mail from this tracker.

I've just added --enable-event-sockets configure option:

Sockets extension is now required by default. However, this requirement can be 
turned off with --disable-event-sockets option. Package maintainers should 
handle this, btw.

If it's okay, I'll package it ASAP.
 [2013-09-07 07:16 UTC]
Uploaded version 1.7.6
 [2013-09-08 02:44 UTC] php-bugs-2013 at ryandesign dot com
Building 1.7.6 with or without --enable-event-sockets doesn't work; it says:

src/util.c:30:2: error: unknown type name 'php_socket'; did you mean 

I still need to manually add -DHAVE_SOCKETS to CFLAGS, as I had to to build 1.7.5.
 [2013-09-08 07:42 UTC]
> Building 1.7.6 with or without --enable-event-sockets doesn't work 
Without --enable-event-sockets this option is implied to be *on*. To disable 
sockets one should use --disable-event-sockets option, which turns off sockets 
support. This means that the sockets extension is required by default, but if 
you configure with --disable-event-sockets, then sockets support is ignored 

You shouldn't define HAVE_SOCKETS yourself anyway. It should be detected 

Moreover, I had removed the checks for HAVE_SOCKETS and COMPILE_DL_SOCKETS.
Instead, I made sockets required(unless --disable-event-sockets option used):

In config.m4:
if test "$PHP_EVENT_SOCKETS" != "no"; then
    PHP_ADD_EXTENSION_DEP(event, sockets)
    AC_DEFINE(PHP_EVENT_SOCKETS, 1, [Sockets extension is required])

PHP_ADD_EXTENSION_DEP without 3rd argument makes extension required.

In php_event.c:

So the sockets extension is required by default, and the checks for its presence 
are made by PHP
in both compile-time and run-time cases.

To build Event successfully we need:
* PHP headers including "ext/sockets/php_sockets.h"(for instance, on my Gentoo I 
have it here: /usr/lib/php5.4/include/php/ext/sockets/php_sockets.h)
* PHP built with --enable-sockets
* phpize version should match php version, namely(my version):
$ phpize --version 

Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525

$ php -i | perl -e 'while(<>){/^(Zend|PHP) / and print $_;}'
PHP Version => 5.4.19-pl0-gentoo
PHP API => 20100412
PHP Extension => 20100525
Zend Extension => 220100525
Zend Extension Build => API220100525,NTS,debug
PHP Extension Build => API20100525,NTS,debug
Zend Signal Handling => disabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
PHP Version => 5.4.19-pl0-gentoo

Probably, you have different versions of PHP installed. Probably, phpize implies 
another version of PHP.

If it still fails, I can also try to help you via SSH, if you wish.
 [2013-09-08 09:02 UTC]
-Status: Closed +Status: Re-Opened
 [2013-09-08 09:02 UTC]
Hmm, I see that $PHP_SOCKETS variable is actually empty when sockets are 
disabled. It means that PHP_ADD_EXTENSION_DEP won't stop with error, since it 
check for "no" string:

With a little hack in our config.m4:
  if test "x$PHP_SOCKETS" = "x"; then

it'll stop configuration with the following error:
configure: error: 
You've configured extension event, which depends on extension sockets,
but you've either not enabled sockets, or have disabled it.

At least, the user can now understand that he/she needs to rebuild PHP with 
sockets enabled.

I'll ask for clarification on the PECL mailing list/IRC.

Let me know if you have ideas, too.
 [2013-09-08 11:53 UTC]
-Status: Re-Opened +Status: Closed
 [2013-09-08 11:53 UTC]
Okay, I figured it out.

The config.m4 macro is used to static building only. The required module 
dependency is checked at run time only.

Our compilation error is caused by absence of defined HAVE_SOCKETS symbol, which 
is normally stored in main/php_config.h when PHP is built with --enable-sockets 
option. But ext/sockets/php_sockets.h wraps all of its code in #if HAVE_SOCKETS 

Working in Gentoo I almost forgot that some distributions use separate packages 
even for the standard extensions bundled with the PHP source. So installing 
"sockets" separately we have no HAVE_SOCKETS symbol defined anywhere.

I've just pushed a workaround. Please checkout the Git version. Unfortunately, 
we've no other way than to define HAVE_SOCKETS ourselves. I'm just checking for 
ext/sockets/php_sockets.h. If the header is present and usable, I define 

I should work this time. If it's okay, I'll upload new package to PECL.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Oct 02 23:05:52 2022 UTC