AFP548 Changing the world one server at a time.

PHP 5.2.6 + fsockopen on localhost

Home › Forums › OS X Server and Client Discussion › Web › PHP 5.2.6 + fsockopen on localhost

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #375831
    Virtual DarKness
    Participant

    Hello,
    on a Mac OS X Server 10.5 with PHP 5.2.6 i’ve a problem with an old php script:

    Warning: fsockopen() [function.fsockopen]: unable to connect to 127.0.0.1:80 (Connection refused) in /path/to/script.php on line 54

    I’ve tried to write a test script with the followin code:

    <?php
    $fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
    if (!$fp) {
        echo "$errstr ($errno)
    \n";
    } else {
        $out = "GET / HTTP/1.1\r\n";
        $out .= "Host: www.example.com\r\n";
        $out .= "Connection: Close\r\n\r\n";
    
        fwrite($fp, $out);
        while (!feof($fp)) {
            echo fgets($fp, 128);
        }
        fclose($fp);
    }
    ?>

    and it works correctly.. so the problems seems to happen when it tries to connect to localhost.

    I’ve also tried to connect to 127.0.0.1 but got the same error.

    any idea? should I change something in my php.ini?

    thanks.

    bye,
    Giovanni.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.