Jump to content
Sign in to follow this  
ryahn

Help with php ping script for arma servers

Recommended Posts

I have been trying to ping the ip and port an arma 2 oa server I have. But it always gives me connection refused. I know the port is open and working because you can connect to it. I am able to ping port 80 and get the online message to appear just fine.

//Connection Info
$ip = "127.0.0.1"; //IP
$port = "2326"; //Port

//Connection
$sock = fsockopen( $ip, $port, $num, $error, 2 ); //2 is the ping time, you can sub what you need

//Check Status

if( !$sock ){

//Closed
       echo( "It appears to be closed" );

}

if( $sock ){

//Open
       echo( "It appears to be open" );
       fclose($sock);

}

I have tried localhost and the server's IP and nothing

Share this post


Link to post
Share on other sites

With a classical, you'll open a connection on TCP port.

Get a try with that:

<?php
$fp = fsockopen("udp://127.0.0.1", 2326, $errno, $errstr);
if (!$fp) {
    echo "ERROR: $errno - $errstr<br />\n";
} else {
    fwrite($fp, "\n");
    echo fread($fp, 26);
    fclose($fp);
}
?>

For recall, port assignation is as bellow:

  • port UDP (game)
  • port+1 UDP (reporting)
  • port+3 UDP (VoN)

Also, to be clear, in your fsockopen, 2 is simply a timeout and it's expressed in seconds (not in ms). More, fsockopen hasn't the reputation to be fast, so if needed, adjust this value.

Edited by tom_48_97
timeout

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×