Created
March 18, 2011 07:53
-
-
Save z0w0/875753 to your computer and use it in GitHub Desktop.
A quick snippet to ping an address with a port with PHP.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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