Exemplo n.º 1
0
 /**
  * Socket pool constructor
  *
  * @param array  $hosts        List of remote hostnames
  * @param mixed  $ports        Array of remote ports, or a single common port
  * @param bool   $persist      Whether to use a persistent socket
  * @param mixed  $debugHandler Function for error logging
  */
 public function __construct($hosts = array('localhost'), $ports = array(9090), $persist = false, $debugHandler = null)
 {
     parent::__construct(null, 0, $persist, $debugHandler);
     if (!is_array($ports)) {
         $port = $ports;
         $ports = array();
         foreach ($hosts as $key => $val) {
             $ports[$key] = $port;
         }
     }
     foreach ($hosts as $key => $host) {
         $this->servers_[] = array('host' => $host, 'port' => $ports[$key]);
     }
 }