dongyan8896 2015-01-20 20:41
浏览 68

我突然发现“无法找到套接字传输'http'”错误。 在我们切换网络之前一切正常

After a network switch, parts of my program that send data to other servers are no longer working.

I tried the following code:

<?php
fsockopen("www.php.net", 80, &$errno, &$errstr, 30);
    if(!$fp) {
        echo "Error: $errstr ($errno)<br>
";
    } else {
        fputs($fp,"GET / HTTP/1.0

");
        while(!feof($fp)) {
            echo fgets($fp,128);
        }
        fclose($fp);
    }
?>

After running that code, I am presented with the following error:

Unable to find the socket transport "http" - did you forget to enable it when you configured PHP? (19)

What do I need to check to ensure this works? It's baffling because it was working fine just before switching networks. I'm also getting the "php_network_getaddresses: getaddrinfo" error when I try get_file_contents.

  • 写回答

1条回答 默认 最新

  • dongmeng1402 2015-01-20 22:05
    关注

    Did you try opening the socket without the protocol part, e.g. just

    fsockopen("www.php.net", 80, &$errno, &$errstr, 30);
    

    I found the answer by doing a google search for

    Unable to find the socket transport "http"

    The same answer is in all of the top 5 results, so it would have saved you 3 days to just spend 5 seconds copying and pasting the error in to google.

    评论

报告相同问题?