[PHP-DEV] Bug #11058: php_network_getaddresses: getaddrinfo failed From: pat <email protected>
Date: 05/23/01

From: pat <email protected>
Operating system: OpenBSD 2.6
PHP version: 4.0.5
PHP Bug Type: HTTP related
Bug description: php_network_getaddresses: getaddrinfo failed

I've seen this issue posted here a few times, and I think my problem is similar to Bug id #7880.

fopen(), fsockopen(), and file() will not work with URL or IP address parameters. include() has the same issue. I believe it has something to do with getaddrinfo.

Before upgrading to PHP4, I was running 3.0.16 and all of these functions were working perfectly with URL parameters.

My configure script looks like this:

./configure --with-apache=/usr/temp/apache_1.3.19 --with-mysql=/usr/local --enable-track-vars --with-xml --with-openssl=/usr/local/ssl

My php.ini DOES contain the line "allow_url_fopen = On"

The fopen() script looks like this:

        $fd = fopen( "http://www.php.net/", "r" );
        if( !$fd )
        {
                echo "Cannot open URL";
        } else {
                while ( !feof( $fd ) ) {
                        $buffer = fgets( $fd, 4096 );
                        echo $buffer;
                }
                fclose ( $fd );
        }

and produces this output:

Warning: php_network_getaddresses: getaddrinfo failed: name or service is not known in /var/www/patrickhaney.com/www/weather/test.php on line 24

Warning: fopen("http://www.php.net/","r") - Bad file descriptor in /var/www/patrickhaney.com/www/weather/test.php on line 24
Cannot open URL

and yes, I can resolve php.net to 208.247.106.187. Using the IP address in place of the hostname produces the same output.

If I use the fsockopen() function with this script:

        fsockopen("http://www.php.net/", 80, &$errno, &$errstr, 30);
        if(!$fp) {
                echo "Error: $errstr ($errno)<br>\n";
        } else {
                fputs($fp,"GET / HTTP/1.0\n\n");
                while(!feof($fp)) {
                        echo fgets($fp,128);
                }
                fclose($fp);
        }

I get this output:

Error: (0)

-- 
Edit Bug report at: http://bugs.php.net/?id=11058&edit=1

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>