fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known
Posted 12 September 2006 - 09:34 PM
I've experienced a problem trying to access URLs which have a hyphen in certain areas of the URL. The URL is constructed like this: "something-.example.com" where the hyphen is immediately before the .example.com bit.
The error received is:
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in ---.php on line 105
Warning: fopen(--): failed to open stream: Permission denied in ---.php on line 105
Is there a workaround for this?
Posted 12 September 2006 - 10:02 PM
$codedhyphen = urlencode('-');
Posted 12 September 2006 - 10:08 PM
Posted 12 September 2006 - 11:01 PM
I get crap sometimes when I don't use entities. Whatever, just a shot man = )
Posted 13 September 2006 - 04:03 PM
Posted 13 September 2006 - 04:38 PM
You're able to open a sample page with a hostname in that format?
Posted 13 September 2006 - 05:34 PM
They all send the UDP request to the DNS server and all receive a reply, but the apps mentioned prematurely give an error. I have to assume that because the apps know what a valid hostname looks like they issue an error because it's "invalid"
I've been able to telnet using the ip address returned from "host" and using the "hostname" in the value for the "Host: " header, retrieve the page needed.
I'm running this from linux. It's possible that all the apps are using the same library and function to do the lookup and it is that function that returns an error. Meaning that all apps are unable to access the specified sites.
If you're using PHP5 the function dns-get-record() is able to retrieve the information needed (ie the ip address). From the look of the example output in the manual, you could loop through the array until you find the "ip" key set and use that ip address to connect to using perhaps curl() or fsockopen.
You'd then use curl to add the "Host:" header with the specified hostname or use fwrite to send the Host: header after connecting with fsockopen.
There may be another way, but those are the ones that come to mind.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users