[PHP] check a host with port responding

  • You can use the following function to check :
$host = "10.207.219.81";

$port = 5900;

check_host($host , $port );

function check_host($hostx,$portx,$waitTimeoutInSeconds){
if($fp = fsockopen($hostx,$portx,$errCode,$errStr,$waitTimeoutInSeconds)){
// It worked
return true;
} else {
// It didn't work
return false;
}
fclose($fp);
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s