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?
Determine if Game is Running from Website
- evenmonkeys
- Posts: 78
- Joined: Thu Feb 13, 2014 1:53 am
- Location: Midwest, US
Re: Determine if Game is Running from Website
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
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
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.
It returns true if the server is up, false if not.
Re: Determine if Game is Running from Website
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
is this possible through HTML
Aideth Elwing, Owner of NIGHTBROOD
http://www/nightbrood.freeforums.net/
http://www/nightbrood.freeforums.net/
Re: Determine if Game is Running from Website
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.