Page 1 of 1
Determine if Game is Running from Website
Posted: Mon Mar 10, 2014 10:07 pm
by evenmonkeys
I have built a website that communicates with the game database and all of it works fine. However, I am trying to show whether the server is online or not. Nothing in the database reflects the server being online or offline. It only shows when the server came up. I have considered pining the computer, but that won't matter because the game doesn't need to be up to respond to the ping.
So I am looking for ideas as to how I can determine if the game is online. How difficult would it be for someone to make something that updates the database every x minutes? I don't want to use anything like a Windows Task because that doesn't know if the server is up and running or not.
So yeah.. anyone have any ideas? Or anything they're already running themselves that I could try?
Re: Determine if Game is Running from Website
Posted: Tue Mar 11, 2014 5:44 pm
by atom0s
If your site is php, just use a raw socket and make a connection to the lobby server. Do not send anything to it, just connect. If it connects fine, the server is considered up.
Code: Select all
/**
* Determines if the server is currently online or not.
*/
function get_server_status()
{
$socket = null;
if (!$socket = @fsockopen( "your_server_address_here", 54230, $errno, $errstr, 1 ))
return false;
@fclose( $socket );
return true;
}
Re: Determine if Game is Running from Website
Posted: Fri Mar 14, 2014 9:25 pm
by tagban
atom0s, I did this and its not giving me an online/offline status properly. Could there be a security setting blocking the ability to ping that port? I mean, the port itself seems fine, so Im assuming there could be a firewall setting? Or option?
Re: Determine if Game is Running from Website
Posted: Fri Mar 14, 2014 10:47 pm
by atom0s
The script connects to the server just like a client does. So if clients can connect the script should as well.
It returns true if the server is up, false if not.
Re: Determine if Game is Running from Website
Posted: Tue Mar 18, 2014 10:02 am
by tagban
Its interesting, it really doesn't like my server, if I do port 80, it works just fine, and detects that its online. But any other port seems to fail, I adjusted firewall, and even turned it off, still no luck..
Re: Determine if Game is Running from Website
Posted: Wed Jul 16, 2014 9:57 pm
by Dang065
is this possible through HTML
Re: Determine if Game is Running from Website
Posted: Wed Jul 16, 2014 10:38 pm
by atom0s
HTML offers no socket connection functionality, so no. The closest you could do is possibly with Javascript. But not sure since I am not a web developer. PHP is the best bet to do it though.