Edit report at http://pear.php.net/bugs/bug.php?id=19709&edit=1
ID: 19709
Comment by: netvoke
Reported By: pear dot php at nurf dot tk
Summary: SOCK_* values are wrong for Solaris
Status: Open
Type: Bug
Package: Net_DNS2
Operating System: Solaris
Package Version: 1.2.4
PHP Version: 5.3.18
New Comment:
Wouldn't something like this do the trick?
in Net/DNS2/Socket.php:
<code>
if ( ! defined( 'SOCK_STREAM' ) )
{
define( 'SOCK_STREAM' , 1 );
}
if ( ! defined( 'SOCK_DGRAM' ) )
{
define( 'SOCK_DGRAM' , 2 );
}
/**
* ...
*/
abstract class Net_DNS2_Socket
{
...
/*
* type of sockets
*/
const SOCK_STREAM = SOCK_STREAM;
const SOCK_DGRAM = SOCK_DGRAM;
...
}
</code>
Of course you could make it conditional like checking OS and setting the
right vars based on it like:
<code>
define( 'SOCK_STREAM' , ( (*SOLARIS*) ? 2 , 1 ) );
</code>
Then again probably something like this is better if you are thinking
future wise:
<code>
if ( ! defined( 'SOCK_STREAM' ) || ! defined( 'SOCK_DGRAM' ) )
{
$_SOCK_STREAM_ = 1;
$_SOCK_DGRAM_ = 2;
if ( *SOLARIS* )
{
$_SOCK_STREAM_ = 2;
$_SOCK_DGRAM_ = 1;
}
if ( ! defined( 'SOCK_STREAM' ) )
{
define( 'SOCK_STREAM' , $_SOCK_STREAM_ );
}
if ( ! defined( 'SOCK_DGRAM' ) )
{
define( 'SOCK_DGRAM' , $_SOCK_DGRAM_ );
}
unset( $_SOCK_STREAM_ , $_SOCK_DGRAM_ );
}
</code>
And, if you want to be independent of the original constants then change
SOCK_STREAM to _SOCK_STREAM_ in case the system is wrong or w/e.
Previous Comments:
------------------------------------------------------------------------
[2012-11-15 17:03:42] orbill
Description:
------------
Hi there,
I ran into a problem on Solaris 10 when using 1.2.4 where 1.2.3 worked
ok.
My code suddenly returned an error "every name server provided has
failed: Protocol not supported".
After a little investigation I found out that SOCK_STREAM and SOCK_DGRAM
have different values on Solaris than for instance Linux:
Solaris
SOCK_STREAM=2
SOCK_DGRAM=1
Linux
SOCK_STREAM=1
SOCK_DGRAM=2
Since 1.2.4 you use your own fixed values instead of the system supplied
values of the sockets extension which then leads to the problem.
A solution would probably be to use the constants from the sockets
extension if available and your own if the extension is not
available...
Regards
Oliver
------------------------------------------------------------------------