<?php

function checkPuerto($dominio,$puerto){
    $starttime = microtime(true);
    $file      = @fsockopen ($dominio, $puerto, $errno, $errstr, 10);
    $stoptime  = microtime(true);
    $status    = 0;
  
    if (!$file){    
        $status = -1;  // Sitio caído
    } else {
        fclose($file);
        $status = ($stoptime - $starttime) * 1000;
        $status = floor($status);
    }
	
	return $status;
     
	 /*
    if ($status <> -1) {
        return true;
    } else {
        return false;
    }
	*/
     
}

//$dominio = "127.0.0.1:8080";
//$dominio = "www.ismypage.com";

//$dominio = "www.palmandina.com";
//$puerto = "80";

$dominio = $_REQUEST['dominio'];
$puerto = $_REQUEST['puerto'];


echo checkPuerto($dominio,$puerto);

?>
