Jump to content


Photo

fsockopen, udp and my small server status script..


  • Please log in to reply
6 replies to this topic

#1 cadric

cadric
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 July 2006 - 02:04 PM

I am trying to get this small script working that I managed to put together. It works...with tcp..but whenever I try to use it with udp(which is what I want to check) the script will always show the server is online, even if its not..

My server will always show it online:
http://einherjers.dk/test/status.php
That port this script use is not open..
Does anyone know what I am doing wrong?

<?php
$host = "udp://einherjers.dk";
$port = "886";

$output = @fsockopen($host, $port, $errno, $errstr, 2);  
if (!$output) {
   echo "<img src='http://einherjers.dk/account3/images/offline.gif' alt='Offline' />";
	} else {
  echo"<img src='http://einherjers.dk/account3/images/online.gif' alt='Online' />";
@fclose($output);}
?>


#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 24 July 2006 - 02:07 PM

What do $errno and $errstr produce?

#3 cadric

cadric
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 July 2006 - 02:15 PM

Ignore..

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 24 July 2006 - 02:34 PM

I know what they do.... Im asking you what they contain.

#5 cadric

cadric
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 July 2006 - 02:46 PM

Oh sorry..

But then I suppose it contains this if I set it too output the error: (0)

#6 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 24 July 2006 - 02:54 PM

What (copy and paste) is the output of....

<?php
$host = "udp://einherjers.dk";
$port = "886";

$output = @fsockopen($host, $port, $errno, $errstr, 2);  
if (!$output) {
   echo "offline: $errno, $errstr";
} else {
   echo "offline: $errno, $errstr";
}
@fclose($output);
?>

when the server is both offline and online?

#7 cadric

cadric
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 24 July 2006 - 03:14 PM

same for both.. and still:

offline: 0,




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users