code: public function connect($host, $port) {
  
          if (!$this->reuseConnection) {
              ErrorHandler::start();
              $sock = fsockopen($host, $port);
              ErrorHandler::stop();
  
              return $sock;
          }
  
          $sock = $this->clientSocket;
  
          if ($sock && !feof($sock)) {
              return $sock;
          }
  
          if (!$sock) {
              ErrorHandler::start();
              $sock = fsockopen($host, $port);
              ErrorHandler::stop();
          } else if (feof($sock)) {
              ErrorHandler::start();
              $sock = fsockopen($host, $port);
              ErrorHandler::stop();
          }
  
          $this->clientSocket = $sock;
  
          return $sock;
      }
docs: @param $host
  @param $port
  
  @return null|resource