Determine if Game is Running from Website

Post Reply
User avatar
evenmonkeys
Posts: 78
Joined: Thu Feb 13, 2014 1:53 am
Location: Midwest, US

Determine if Game is Running from Website

Post by evenmonkeys » Mon Mar 10, 2014 10:07 pm

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?

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: Determine if Game is Running from Website

Post by atom0s » Tue Mar 11, 2014 5:44 pm

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;
    }

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Determine if Game is Running from Website

Post by tagban » Fri Mar 14, 2014 9:25 pm

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?

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: Determine if Game is Running from Website

Post by atom0s » Fri Mar 14, 2014 10:47 pm

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.

User avatar
tagban
Posts: 352
Joined: Fri Dec 28, 2012 11:31 am
Location: Pennsylvania, USA

Re: Determine if Game is Running from Website

Post by tagban » Tue Mar 18, 2014 10:02 am

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

Dang065
Posts: 26
Joined: Mon Nov 11, 2013 4:46 am

Re: Determine if Game is Running from Website

Post by Dang065 » Wed Jul 16, 2014 9:57 pm

is this possible through HTML
Aideth Elwing, Owner of NIGHTBROOD
http://www/nightbrood.freeforums.net/

User avatar
atom0s
Developer
Posts: 537
Joined: Thu Oct 25, 2012 9:52 am

Re: Determine if Game is Running from Website

Post by atom0s » Wed Jul 16, 2014 10:38 pm

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.

Post Reply