PHP Open port check

I threw this little script together today when checking why a PHP/Flash/MySQL application has stopped working.
The application itself looks and works fine, but I suspected a firewall block between the web server and database server. Without SSH access to this shared server I had to get inventive.
So I tested that PHP could open a socket on the right port to my server…

<?php
$site = "www.google.com";
$port = 80;
$fp = fsockopen($site,$port,$errno,$errstr,10);
if(!$fp) {
echo "Cannot connect to server: $errno - $errstr";
} else {
echo "Connect was successful - no errors on Port ".$port." at ".$site;
fclose($fp);
}
?>
Farhamdani

Sharing insights on tech, blogging, and passive income. Follow for more at farhamdani.eu.org!

Drop your comments, but make sure they’re related to the discussion!

I'd be grateful if you could read the Commenting Rules on this blog before posting a comment.

Post a Comment (0)
Previous Post Next Post