Jump to content

fsockopen, udp and my small server status script..


cadric

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]
Link to comment
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?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.