php.net |  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
Votes:2
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-11 18:43 UTC] nlopess@php.net
Wez, can you please take a look at my patch?
http://mega.ist.utl.pt/~ncpl/php_7132_patch.txt

test script:
<?
$bogus = 'www.aasaaaaaaaaaaaaa.net';

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

This patch also fixes the problem of having two warnings generated, instead of just one.
 [2005-08-11 19:11 UTC] nlopess@php.net
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] jani@php.net
-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] jani@php.net
errstr is set, errno isn't.
 [2013-07-30 03:47 UTC] yohgaki@php.net
-Status: Assigned +Status: Closed
 [2013-07-30 03:47 UTC] yohgaki@php.net
It seems this is fixed.

<?php
$bogus = 'www.aasaaaaaaaaaaaaa.net';

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



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

Warning: fsockopen(): unable to connect to www.aasaaaaaaaaaaaaa.net:80 
(php_network_getaddresses: getaddrinfo failed: Name or service not known) in - 
on line 4
0
string(71) "php_network_getaddresses: getaddrinfo failed: Name or service not 
known"
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC