Threads

hostcheck.php


<?php
  
require('HostCheck.class.php');

  
$hosts= array(
    
'test.edu:443',
    
'php3.de:25',
    
'blup.blop:1010',
    
'localhost:80',  
    
'localhost:6100'
  
);
  
  
// {{{ main
  
$c= new HostCheck();
  foreach (
array_keys($hosts) as $t) {
    list(
$host$port)= explode(':'$hosts[$t]);
    
    
$c->check($host$port);
  }
  
  
sleep(10);
  
  foreach (
array_keys($c->threads) as $t) {
    
printf("---> Waiting to join %d (%s)\n"$tvar_export($c->threads[$t], 1));
    
    if (!
$c->threads[$t]) continue; // WTF?
    
var_dump($c->threads[$t]->join());
  }
  
  
printf("DONE\n");
  
// }}}
?>