I've just moved a site that has always worked fine to a new server, and am now encountering sporatic problems with readfile() calls that use a hostname in their reference. At times the calls work fine, but when it's not working, I get:
php_hostconnect: connect failed
and then of course the readfile() fails due to bad file descriptor.
I am using PHP 4.0.6. Yes, I know it's old, but it's the latest one there's a Red Hat package for, and this cannot be the problem because I used the exact same version on another machine without ever encountering this problem). This machine is using identical versions of all related software, and my php.ini is exactly the same.
I've set up test pages and info pages on two different machines so you can compare for yourself. As I mentioned, the problem is sporatic so it may or may not be working when you go there.
Working Machine:
http://207.228.75.228/~jason/phpinfo.php
http://207.228.75.228/~jason/readfile_test.php
Machine That Breaks Sometimes:
http://www.insidemacgames.com/misc/phpinfo.php
http://www.insidemacgames.com/misc/readfile_test.php