Ejemplo n.º 1
0
 public function connect($remote_address, $remote_port)
 {
     $this->connecting = true;
     try {
         parent::connect($remote_address, $remote_port);
     } catch (socketException $e) {
         echo "Caught exception: " . $e->getMessage() . "\n";
     }
 }
Ejemplo n.º 2
0
 /**
  * Enters passive mode and opens a data connection
  * @param resource $sock Reference to the data connection stream
  * @returns boolean True on success
  */
 function pasv(&$sock)
 {
     $this->write("PASV\r\n");
     $success = $this->chat("227");
     if ($success) {
         // where to connect?
         preg_match("/\\(([\\d,]*)\\)/", $this->last(), $match);
         $match = explode(",", $match[1]);
         if (isset($match[5])) {
             $host = "{$match[0]}.{$match[1]}.{$match[2]}.{$match[3]}";
             $port = $match[4] * 256 + $match[5];
             $sock = new socket();
             $sock->connect($host, $port);
             if ($sock->status()) {
                 return true;
             } else {
                 $this->error(__("Couldn't open data connection to %s:%s.", $host, $port), E_USER_ERROR);
                 return false;
             }
         } else {
             $this->debug($match, __FILE__, __LINE__);
         }
     }
 }