Skip to content

Instantly share code, notes, and snippets.

@z0w0
Created March 18, 2011 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z0w0/875753 to your computer and use it in GitHub Desktop.
Save z0w0/875753 to your computer and use it in GitHub Desktop.
A quick snippet to ping an address with a port with PHP.
//These values will ping a minecraft server (I've chosen some random dedi-server here)
$address = "mc.pewpew.dk";
$port = 25565;
$timeout = 3; //3 seconds before giving up
$fp = fsockopen($address,$port,$errno,$errstr,$timeout);
if(!$fp)
{
echo "fail";
}
else
{
fclose($fp);
echo "success";
}
//You could use these for a minecraft server status thing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment