CheckThread.class.php
<?php
class CheckThread extends Thread {
public
$host = '',
$port = 0,
$res = 0;
private
$fd = NULL,
$e = 0,
$n = '';
public function __construct($host, $port) {
$this->host= $host;
$this->port= $port;
}
public function run() {
printf("---> Trying %s:%d\n", $this->host, $this->port);
$this->fd= @fsockopen($this->host, $this->port, $this->n, $this->e);
if ($this->fd) {
$this->res= '+OK '.$this->host.':'.$this->port;
fclose($this->fd);
} else {
$this->res= '-ERR '.$this->host.':'.$this->port.' ['.$this->n.']: '.$this->e;
}
printf(" >> %s\n", $this->res);
return $this->res;
}
public function __destruct() {
printf("===> Destruct thread for %s:%d\n", $this->host, $this->port);
}
}
?>