Jump to content
  • 0

Statut server with php


jtssi

Question

Hello, I'm looking for a way via my website to display the status of the server whether it is online or not. On the internet I found code vouchers but it doesn't work:

 

<?php
$debug = true;
$site = 'udp://xxx.xxx.xxx.xxx';
$port = '5400';
$check = fsockopen( $site, $port, $errno, $errstr, 6 );
if ( ! $check ) {
   if($debug){
      echo "Error #$errno : $errstr <br>";
   }
   echo 'Offline';     
}
else {
   echo 'Online';
}

?>

whether I put one port or the other it always tells me online

thank you for your help

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Instead of trying to query your server directly (which won't work until the API is available) use our status checker within your script:

https://www.ascensiongamedev.com/resources/status.php?host=xxx.xxx.xxx.xxx&port=5400

 

That will return a number.

 

    -1: Server is offline or unreachable

>= 0: Number of players online.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...