|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #7132 fsockopen doesn't report dns lookup failure
Submitted: 2000-10-11 06:36 UTC Modified: 2013-07-30 03:47 UTC
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: kaufmann at cyland dot com Assigned: wez (profile)
Status: Closed Package: Streams related
PHP Version: 5.3 OS: *
Private report: No CVE-ID: None
 [2000-10-11 06:36 UTC] kaufmann at cyland dot com
fsockopen doesn't report dns lookup failure in errno and errstr. It would be nice if this error was passed including a hint what is wrong with the call to fsockopen. Debugging of skripts using sockets would become easier.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-11 18:43 UTC]
Wez, can you please take a look at my patch?

test script:
$bogus = '';

fsockopen($bogus, 80, $errno, $errstr);
echo $errno, "\n";

This patch also fixes the problem of having two warnings generated, instead of just one.
 [2005-08-11 19:11 UTC]
BTW, the script I've provided leaks with or without my patch (with zend mm disabled)! The problematic part is the simple "echo $errno;".
 [2010-12-01 15:45 UTC]
-Package: Feature/Change Request +Package: Streams related -Operating System: SuSE Linux 6.4 +Operating System: * -PHP Version: 4.0.2 +PHP Version: 5.3
 [2010-12-01 15:45 UTC]
errstr is set, errno isn't.
 [2013-07-30 03:47 UTC]
-Status: Assigned +Status: Closed
 [2013-07-30 03:47 UTC]
It seems this is fixed.

$bogus = '';

fsockopen($bogus, 80, $errno, $errstr);
echo $errno, "\n";

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or 
service not known in - on line 4

Warning: fsockopen(): unable to connect to 
(php_network_getaddresses: getaddrinfo failed: Name or service not known) in - 
on line 4
string(71) "php_network_getaddresses: getaddrinfo failed: Name or service not 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC