#44065 [Opn]: fsockopen() throws warning and doesn't return error

From: Date: Thu, 07 Feb 2008 01:12:41 +0000
Subject: #44065 [Opn]: fsockopen() throws warning and doesn't return error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122059@lists.php.net to get a copy of this message
ID: 44065 Updated by: msaraujo@php.net Reported By: joe at digg dot com Status: Open Bug Type: Streams related Operating System: Linux devwww25 2.6.12-1-amd64-k8 PHP Version: 5.2.5 New Comment: 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) Previous Comments: ------------------------------------------------------------------------ [2008-02-07 00:48:42] 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 00:44:42] msaraujo@php.net Hello, I have not been able to reproduce it. Can please give us an extra explanation about it? ------------------------------------------------------------------------ [2008-02-06 22:37:42] 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) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44065&edit=1

« previous php.bugs (#122059) next »