php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44065 fsockopen() throws warning and doesn't return error
Submitted: 2008-02-06 22:37 UTC Modified: 2008-07-25 01:00 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:0 (0.0%)
From: joe at digg dot com Assigned: fb-req-jani (profile)
Status: No Feedback Package: Streams related
PHP Version: 5.2.5 OS: Linux devwww25 2.6.12-1-amd64-k8
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: joe at digg dot com
New email:
PHP Version: OS:

 

 [2008-02-06 22:37 UTC] joe at digg dot com
Description:
------------
When getaddrinfo fails fsockopen() fails to return an error string or error code.

Reproduce code:
---------------
<?php

$code = 0;
$message = '';
$fp = fsockopen('www.asdf98070978.org', 80, $code, $message);
if (!is_resource($fp)) {
    echo 'ERROR: ' . $message . '(#' . $code . ')' . "\n";
} else {
    echo 'Connected!' . "\n";
    fclose($fp);
}

?>


Expected result:
----------------
fsockopen() should return false and set an appropriate error code and error message.

Actual result:
--------------
It spits out a warning and doesn't include any sort of error message or string:

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/jstump/repository/wildcat/branches/config/foo.php on line 5

Warning: fsockopen(): unable to connect to www.asdf98070978.org:80 (Unknown error) in /home/jstump/repository/wildcat/branches/config/foo.php on line 5
ERROR: (#0)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-07 00:44 UTC] msaraujo@php.net
Hello,

I have not been able to reproduce it. Can please give us an extra explanation about it? 



 [2008-02-07 00:48 UTC] joe at digg dot com
Did you run the reproduce code? I can consistently reproduce no error and warnings being thrown from many machines. What was the output when you ran the code below? Though, depending on the machine, I sometimes get an error code.
 [2008-02-07 01:12 UTC] msaraujo@php.net
Hello,

Got the same with 5.2.5 and 6 (32 bits machine)

[root@porcupine bugs]# /usr/local/php6/bin/php fsockopen.php

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /root/bugs/fsockopen.php on line 6

Warning: fsockopen(): unable to connect to www.asdf98070978.org:80 (Unknown error) in /root/bugs/fsockopen.php on line 6
ERROR: (#4)

 [2008-07-17 23:39 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

Seems to be fixed since I get this:

ERROR: php_network_getaddresses: getaddrinfo failed: Name or service not known(#0)

Note: The code is 0 always when failure happens before connect() (also mentioned in the friendly manual :)
 [2008-07-25 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC