Bug #1894: gethostbyname returns "255.255.255.255"

From: Date: Tue, 27 Jul 1999 17:42:18 +0000
Subject: Bug #1894: gethostbyname returns "255.255.255.255"
Groups: php.dev 
Request: Send a blank email to php-dev+get-9236@lists.php.net to get a copy of this message
From: pete.nelson@ci.stpaul.mn.us Operating system: SGI Irix 6.2 PHP version: 3.0.11 PHP Bug Type: Misbehaving function Bug description: gethostbyname returns "255.255.255.255" I wanted to make a hostname lookup page, and realized that it couldn't be done on either of my SGI indys. It works fine under RedHat linux, Win98 & WinNT (all running apache 1.3.6). My guess is a bug in the SGI system libraries - it does get a little nutty. Here's my script: <html><head><title>Host Checker</title></head> <body bgcolor=white> <h1>Test a Host</h1> <?php if(! isset($host)) { $host = "friday"; } // The Input: echo "<form action=\"http-check.php3\" method=post>"; echo "<input type=text name=host size=30 value=\"$host\">"; echo "<input type=submit value=\"Check Host\">"; echo "</form>"; // Check DNS $ip = gethostbyname($host); echo "<h2>DNS Entry for <font size=+3 color=blue>$host</font></h2>\n"; echo "<b>$host:</b> $ip\n"; // The HTTP Request: echo "<p><hr align=center width=85%>"; echo "<h2>HTTP Response from <font size=+3 color=blue>$host</font></h2>\n"; $fp = fsockopen("$ip", 80, &$errnr, &$errstr); if(! $fp) { echo "<h1><font color=red>Error!</font></h1>"; echo "<p>$errstr ($errnr)"; exit; } fputs($fp, "HEAD / HTTP/1.0\n\n"); // The HTTP Response: while(!$end) { $line = fgets($fp, 2048); if(trim($line) == "") { $end = true; } else { echo "<BR>$line"; } } fclose($fp); ?> </body></html>

« previous php.dev (#9236) next »