#26805 [NEW]: fsockopen fails when hostname is given
| From: | mark dot salisbury at hp dot com | Date: | Tue, 06 Jan 2004 01:18:17 +0000 |
| Subject: | #26805 [NEW]: fsockopen fails when hostname is given | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-52840@lists.php.net to get a copy of this message | ||
From: mark dot salisbury at hp dot com
Operating system: hpux
PHP version: 4.3.4
PHP Bug Type: Sockets related
Bug description: fsockopen fails when hostname is given
Description:
------------
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);
to:
$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.
--
Edit bug report at http://bugs.php.net/?id=26805&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26805&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26805&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26805&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26805&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26805&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=26805&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=26805&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26805&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26805&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26805&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26805&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26805&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26805&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26805&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26805&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26805&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26805&r=float