|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26805 fsockopen fails when hostname is given
Submitted: 2004-01-05 20:18 UTC Modified: 2004-01-15 01:08 UTC
Avg. Score:3.0 ± 2.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mark dot salisbury at hp dot com Assigned:
Status: No Feedback Package: Sockets related
PHP Version: 4.3.4 OS: hpux
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: mark dot salisbury at hp dot com
New email:
PHP Version: OS:


 [2004-01-05 20:18 UTC] mark dot salisbury at hp dot com
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);


$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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-06 04:37 UTC]
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

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.

 [2004-01-15 01:08 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 15:01:32 2024 UTC