예제 #1
0
function GetLatency($host, $port)
{
    /**
        -> composer.json
        ======================================
        {
            "minimum-stability": "dev",
            "require": {
                "geerlingguy/ping": "1.*@dev"
            }
        }
        ======================================
        **/
    #$host = "www.google.com.tr";
    #$port = 443;
    $handle = new Ping($host);
    if (isset($port)) {
        $handle->setPort($port);
    }
    $latency = $handle->ping("fsockopen");
    $status = array("<div class='online'> {$latency} ms </div>", "<div class='offline'>Error</div>");
    if ($latency !== false) {
        return $status[0];
    } else {
        return $status[1];
    }
}
예제 #2
0
파일: PingTest.php 프로젝트: hydrawiki/ping
 public function testPort()
 {
     $port = 2222;
     $ping = new Ping($this->reachable_host);
     $ping->setPort($port);
     $this->assertEquals($port, $ping->getPort());
 }
예제 #3
0
파일: Ping.php 프로젝트: dannyweeks/mersey
 /**
  * @param int $port
  * @return $this
  */
 public function setPort($port)
 {
     parent::setPort($port);
     return $this;
 }
예제 #4
0
파일: ping.php 프로젝트: spigotx/HomeLab2
/**
	-> composer.json
	======================================
	{
		"minimum-stability": "dev",
		"require": {
			"geerlingguy/ping": "1.*@dev"
		}
	}
	======================================
	**/
/**
 * vendor/autoload.php dosyası Composer tarafından
 * oluşturulmaktadır.
 */
require "vendor/autoload.php";
use JJG\Ping;
# Host adresi ( IP adreside girilebilir. )
$host = "www.google.com.tr";
# Port numarası ( girmesenizde olur. )
$port = 443;
$handle = new Ping($host);
if (isset($port)) {
    $handle->setPort($port);
}
$latency = $handle->ping("fsockopen");
if ($latency !== false) {
    echo "Latency is {$latency} ms";
} else {
    echo "Host could not be reached.";
}