Author Topic: Get server status via php  (Read 2153 times)

0 Members and 1 Guest are viewing this topic.

Offline Stuffy

  • Soldier
  • **
  • Posts: 182
  • Very stuffy.
    • Climb-Zone Forum
Get server status via php
« on: February 14, 2011, 10:54:28 am »
Hello, is it possible to get the status of a soldatserver with php? I know, there's u13sss, but its a bit overpowert for my needs. I just need to know if the soldatserver is running or not.
The truth is out there? Does anyone know the URL?
The URL is here

Offline darDar

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 794
    • #Soldat Gather - Community on Discord
Re: Get server status via php
« Reply #1 on: February 14, 2011, 11:58:08 am »
would also be interested in that
Soldat Gather 'Matchmaking Community on Discord'

gather.soldat.pl

| My Maps: ctf_Pyramid, ctf_Replay, ctf_Blako, ctf_R6, ctf_Ntex, ctf_Caro, ctf_Bizar & vs_mode mappack |

Offline JotEmI

  • Soldier
  • **
  • Posts: 188
Re: Get server status via php
« Reply #2 on: February 14, 2011, 11:58:55 am »
You can check lobby (Client-Lobby_Protocol) or gamestat.txt (Map/Files Downloading)

Offline SyavX

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 338
Re: Get server status via php
« Reply #3 on: February 14, 2011, 01:05:06 pm »
Code: (php) [Select]
function checkServer($host, $port)
{
        $host = gethostbyname($host);
        $socket = @fsockopen($host, $port, $errno, $errstr, 0.6);
        if ($socket)
        {
                fclose($socket);
                return TRUE;
        }
        else
        {
                fclose($socket);
                return FALSE;
        }
}

$host = '127.0.0.1';
$port = '23073';

echo "server {$host}:{$port} is ";
if (checkServer($host, $port))
{
        echo "ON";
}
else
{
        echo "OFF";
}
« Last Edit: February 14, 2011, 01:09:57 pm by SyavX »

Offline Stuffy

  • Soldier
  • **
  • Posts: 182
  • Very stuffy.
    • Climb-Zone Forum
Re: Get server status via php
« Reply #4 on: February 14, 2011, 01:14:41 pm »
Yeah, SyavX, thats what I'm looking for. Thank you. Im new to php, so I need something I can expand on.

And the Client-Lobby_Protocol is interesting.
« Last Edit: February 14, 2011, 01:18:18 pm by Stuffy »
The truth is out there? Does anyone know the URL?
The URL is here

Offline JotEmI

  • Soldier
  • **
  • Posts: 188
Re: Get server status via php
« Reply #5 on: February 14, 2011, 03:57:47 pm »
Actually simply checking if socket connected is not the best way, at least not the most accurate. Often server freezes (process becomes zombie) and while connection can still be established server itself cannot be joined. That's why I try to get gamestat.txt from the server. If it sends the file = server on, if not = server off/freez.