Server Detector no longer working

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Hi guys,

I run a game server (for a game I'm writing in development).  I had a
routine on my web site which detected if the server was up or down and
displayed a icon, so that people could see from the web page if the
server was working or not.

I just changed where my web page is hosted, and the routine no longer
works, and I can't figure out why.  Can anyone give me any clues?

Here is the routine (taking out the IP address and port numbers)

if(($sock = socket_create (AF_INET, SOCK_DGRAM, 0)) < 0)
  echo "socket_create() failed: reason: " . socket_strerror($sock) .
  $send=sprintf('%c%c%c%c',24, 0, 0, 0);

  $bar = array($sock);
  $select_result = socket_select($bar, $b=null, $c=null, 3);
  if ($select_result == true)
    $LauncherPopulation = sprintf('%d%d%d%d%d',$recvbuf[0],
$recvbuf[2], $recvbuf[3], $recvbuf[4]);
    $LauncherPopulation = ltrim($LauncherPopulation, '0');
    if ($LauncherPopulation == '')
        $LauncherPopulation = '0';
    $ClientPopulation = sprintf('%d%d%d%d%d',$recvbuf[5], $recvbuf[6],
$recvbuf[7], $recvbuf[8], $recvbuf[9]);
    $ClientPopulation = ltrim($ClientPopulation , '0');
    if ($ClientPopulation == '')
        $ClientPopulation = '0';

    echo "<CENTER>The Sovereignty Server<BR>";
    echo "is UP</CENTER><BR>";
    <CENTER><img src="GreenGem.png" border="0"></CENTER>
    echo "<CENTER>Launcher Population: " . $LauncherPopulation .
    echo "Client Population: " . $ClientPopulation .
    echo "<CENTER>The Sovereignty Server<BR>";
    echo "is DOWN</CENTER><BR>";
    <CENTER><img src="RedGem.png" border="0"></CENTER>

Any ideas why this no longer works?   The current result is that the
page just hangs at this routine.  My preliminary experiments seem to
suggest that $select_result now always returns true, even when the
server is off.

When the server is running, the code works fine, the green gem comes
up, the population values are correct. It's only when the server is
NOT running that the web page locks up. $select_result is definitely
returning a false positive when the server is down (which it didn't
used to do before).  As a result, the page is locking up at the
recvfrom() line (because there is no server running to send the data

Thanks for any advice.


Site Timeline