#26805 [Opn->Fbk]: fsockopen fails when hostname is given
| From: | wez@php.net | Date: | Tue, 06 Jan 2004 09:37:33 +0000 |
| Subject: | #26805 [Opn->Fbk]: fsockopen fails when hostname is given | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-52848@lists.php.net to get a copy of this message | ||
ID: 26805
Updated by: wez@php.net
Reported By: mark dot salisbury at hp dot com
-Status: Open
+Status: Feedback
Bug Type: Sockets related
Operating System: hpux
PHP Version: 4.3.4
New Comment:
Sounds like an ipv6 problem; can you try configuring
PHP using --disable-ipv6 and see if that "fixes" the
problem? (either your v6 stack is broken, or it is
misconfigured).
Also, it would be good if you could test a php5 snapshot
with that script (just the CLI version will do), as it has
some code to detect and avoid this problem at runtime.
Previous Comments:
------------------------------------------------------------------------
[2004-01-05 20:18:17] mark dot salisbury at hp dot com
Description:
------------
I was using fsockopen in a script, which worked fine until I upgraded
from version 4.2.0 to 4.3.4. Oddly, I found a workaround for the bug
by changing my code from:
$fp = fsockopen($server_name, $port, $errno, $errstr);
to:
$fp = fsockopen(gethostbyname($server_name), $port, $errno, $errstr);
Reproduce code:
---------------
fsockopen($server_name, $port, $errno, $errstr);
Expected result:
----------------
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed:
host nor service provided, or not known in
/local/apache1.3/htdocs/php_includes/http_post.php on line 45
Warning: fsockopen(): unable to connect to saturn:81 in
/local/apache1.3/htdocs/php_includes/http_post.php on line 45
(errno=0 and errstr="error 0", I believe)
The reason I believe this is a bug is that:
a) Isn't fsockopen going to do something similiar to gethostbyname() if
you pass a hostname and not an IP address to fsockopen? Why does it
work when I pass it an IP address and not the host name? I would
expect gethostbyname to fail also if my problem were external (DNS).
b) everything worked fine until I upgraded PHP today.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26805&edit=1