Page 1 of 1

gethostbyname function

Posted: Thu Apr 14, 2005 1:44 pm
by Ian Wright
After transferring my web access from ADSL to SDSL gethostbyname() fails. The code worked fine on the ADSL line.
The error message code reads:
PHP Warning: fsockopen(): php_network_getaddresses: gethostbyname failed
in <my PHP program> on line 29
PHP Warning: fsockopen(): unable to connect to
<domain name>:80 in <my PHP program> on line 29
Only two things have been changed between working and not working: (1) SDSL line for ADSL line (2) SDSL modem for ADSL modem.
Here's the code fragment:

Code: Select all

function pullpage( $host, $usepath, $postdata = &quote;&quote; ) {
	# open socket to filehandle(epdq encryption cgi)
	$fp = fsockopen( $host, 80, $errno, $errstr, 60 );
	# check that the socket has been opened successfully
	if( !$fp ) {
		$errorString = &quote;<p>$errstr ($errno)</p>&quote;;
		$errorStatus = true;
	}
Any suggestions for a fix for gethostbyname would be welcome.

Posted: Thu Apr 14, 2005 3:22 pm
by Chris Corbyn
Are you behind a firewall or proxy?

Posted: Thu Apr 14, 2005 4:39 pm
by Ian Wright
Firewall: that which is built into my SDSL modem. It is open inbound on port 80 only.

Posted: Fri Apr 15, 2005 6:54 am
by Ian Wright
Problem resolved.
For the record, the ADSL model set the LAN address of the server, but the SDSL modem does not have that feature, so the server's network configuration was set with a fixed network IP address. That in turn disabled the automatic DNS, so gethostbyname() didn't have anything to refer to. Fix was to enter the modem/gateway IP address into the server's LAN configuraton. Easy when you know what to look for!