|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-11-18 10:08 UTC] phil at lavin dot me dot uk
Description:
------------
When connecting to an IPv6 address, either hostname or raw address in [] an 'unknown error' is thrown. This problem occurs on both Linux and BSD and both test machines can correctly telnet to the requested address.
phil@127dot0dot0dot1:~$ php info.php | grep -i ipv6
IPv6 Support => enabled
phil@127dot0dot0dot1:~$
Reproduce code:
---------------
<?php
$a = fsockopen('[2610:1e8:2900:a::8]', 6667);
if ($a) { echo 'yay'; } else { echo 'nay'; }
?>
Expected result:
----------------
The code should echo 'yay'.
Actual result:
--------------
Warning: fsockopen(): unable to connect to [2610:1e8:2900:a::8]:6667 (Unknown error) in /root/test.php on line 2
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 21:00:01 2025 UTC |
# sapi/cli/php -r 'var_dump(fsockopen("[2610:1e8:2900:a::8]", 6667));' Warning: fsockopen(): unable to connect to [2610:1e8:2900:a::8]:6667 (Network is unreachable) ..so I'd say your system is either misconfigured or missing ipv6 support or the target is not there. :)I have just tested it on 5 different servers running 5.2.11. All give the same error, e.g. phil@server:~$ php -r 'var_dump(fsockopen("[2610:1e8:2900:a::8]", 6667));' Warning: fsockopen(): unable to connect to [2610:1e8:2900:a::8]:6667 (Unknown error) in Command line code on line 1 bool(false) You have new mail in /var/mail/phil phil@server:~$ This is regardless of whether they do or don't have IPv6 support. A server running 5.2.9 gives what you got: phil@server1:~$ php -r 'var_dump(fsockopen("[2610:1e8:2900:a::8]", 6667));' Warning: fsockopen(): unable to connect to [2610:1e8:2900:a::8]:6667 (Network is unreachable) in Command line code on line 1 bool(false) phil@server1:~$ PhilIt's properly configured if it's not disabled in configure line with --disable-ipv6 option. f.e.: # rm -f config.cache && ./configure && make # sapi/cli/php -r 'var_dump(fsockopen("[2610:1e8:2900:a::8]", 6667));' Warning: fsockopen(): unable to connect to [2610:1e8:2900:a::8]:6667 (Network is unreachable)..Having just downloaded and compiled 5.2.11 (just using ./configure with no options)... phil@127dot0dot0dot1:~/php5/php-5.2.11$ sapi/cli/php -r 'var_dump(fsockopen("[2610:1e8:2900:a::8]", 6667));' Warning: fsockopen(): unable to connect to [2610:1e8:2900:a::8]:6667 (Unknown error) in Command line code on line 1 bool(false) phil@127dot0dot0dot1:~/php5/php-5.2.11$ Philphil@127dot0dot0dot1:~/php5/php5.2-200911190930$ sapi/cli/php -r 'var_dump(fsockopen("[2610:1e8:2900:a::8]", 6667));' resource(4) of type (stream) phil@127dot0dot0dot1:~/php5/php5.2-200911190930$ I assume this fix will be pushed out in 5.2.12? Phil