Jump to content

Archived

This topic is now archived and is closed to further replies.

cadric

fsockopen, udp and my small server status script..

Recommended Posts

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?

[code]
<?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);}
?>
[/code]

Share this post


Link to post
Share on other sites
What do $errno and $errstr produce?

Share this post


Link to post
Share on other sites
I know what they do.... Im asking you what they contain.

Share this post


Link to post
Share on other sites
Oh sorry..

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

Share this post


Link to post
Share on other sites
What (copy and paste) is the output of....

[code=php:0]
<?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);
?>
[/code]

when the server is both offline and online?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.