Esempio n. 1
0
 function connect()
 {
     $this->reset_error();
     if (is_null(self::$cnx)) {
         // Connection failed!
         $this->set_error("Can Not Connect");
         return false;
     }
     if (self::$cnx === false) {
         try {
             // if the box isnt on this timeout is ignored and is likely to be different
             if (!isset($this->config['timeout'])) {
                 $timeoutarray = array('seconds' => 5, 'milliseconds' => 1);
             } else {
                 $timeoutarray = array('seconds' => $this->config['timeout'], 'milliseconds' => 1);
             }
             self::$cnx = @new Rserve_Connection($this->config['host'], $this->config['port'], $timeoutarray);
         } catch (exception $except) {
             self::$cnx = null;
             $this->set_error('Can Not Connect');
             return false;
         }
         $this->setup_R();
         return true;
     } else {
         // We are connected
         return true;
     }
 }