1

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>\n";
    } else {
        fputs($fp,"GET / HTTP/1.0\n\n");
        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.

Mike N
  • 13
  • 1
  • 9
  • What google searches have you tried? :) – Phil Jan 20 '15 at 20:47
  • 1
    possible duplicate of [fsock: Unable to find the socket transport "http"](http://stackoverflow.com/questions/9965430/fsock-unable-to-find-the-socket-transport-http) – Phil Jan 20 '15 at 20:49
  • I've been at this for 3 days now, so i've searched everything I could find, but not finding much help. – Mike N Jan 20 '15 at 21:10

1 Answers1

0

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.

Phil
  • 1,996
  • 1
  • 19
  • 26
  • I did lookup all the first page results for that search term, and none of them solved my problem or were relevant to my issue. When I remove the 'http://' like you suggested, I get the following error: "php_network_getaddresses: getaddrinfo failed: No such host is known." – Mike N Jan 21 '15 at 17:15
  • Everything I read regarding the getaddrinfo failed error suggested there were DNS problems. I've called my ISP and the DNS servers are set correctly. Im just stuck. – Mike N Jan 21 '15 at 17:35
  • So what does your fsockopen line look like now? Please update your question. – Phil Jan 21 '15 at 17:44
  • Seems my outgoing requests work when using an ip address instead of a domain name. – Mike N Jan 21 '15 at 18:36
  • It must be a dns issue then. Are you on a managed server or do you have ssh access? – Phil Jan 21 '15 at 20:30