Member Avatar for yoni0505

I want to do a check for game servers if they are online or not.
I tried using this method but it gives me false-positive:

if(! $sock = @fsockopen("udp://".$ip, $port, $errno, $errstr, 5))
{
    //offline
}
else
{
    //online
    fclose($sock);
}

I tried to enter random IP addresses and even to open some game server and close it and it always doesn't return that the server is online (unless i enter IP like 255.255.255.255)

There is any other method to check server status? (mainly offline/online)

Recommended Answers

All 2 Replies

Seems that a Ping is the standard way to see if you are getting a response.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.