Jump to content

[SOLVED] Server query


regdude

Recommended Posts

Hi!

I made a simple query for a server, JK3 btw, because couldn't find any queries and LGSL always crashed my apache server.

But there is a problem, I want to add the server monitor on a page, but the page wouldn't load if the server is down.

This I have to connect to the server, but since UDP is connectionless then this can't be used if server is up.

$fp = fsockopen("udp://ip", 29070, $errno, $errstr, 200);
if (!$fp) {
    echo "ERROR: $errno - $errstr<br />\n";
}

Also have this, but that doesn't seem to work.

if(fwrite($fp, $packet)) {
//...
}

How could I test if the server is up?

Link to comment
https://forums.phpfreaks.com/topic/156629-solved-server-query/
Share on other sites

I'm not aware of what udp://ip is, but can't you check it against a page on your server? Say you have index.php on www.domain.com/index.php, then:

$fp = @fsockopen('www.domain.com/index.php', 80, $errno, $errstr, 10);
if (!$fp) echo 'Server is down';

 

Though, I like cURL more. Both should work though.

Link to comment
https://forums.phpfreaks.com/topic/156629-solved-server-query/#findComment-824744
Share on other sites

Archived

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

×
×
  • 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.