docs: def connect(self):
          """
          Connect to the server.  This method causes the SimpleRPC
          object to switch to client mode.  Note some methods, such as
          the ping() method, implicitly call this method.
          """
  
          # Make sure we're in client mode
          if self.mode and self.mode != 'client':
              raise ValueError("%s is not in client mode" %
                               self.__class__.__name__)
          self.mode = 'client'
  
          # If we're connected, nothing to do
          if self.conn:
              return
  
          # OK, attempt the connection
          fd = socket.create_connection((self.host, self.port))
  
          # Initialize the connection object
          self.conn = self.connection_class(fd)
  
          # Authenticate
          try:
              self.conn.send('AUTH', self.authkey)
              cmd, payload = self.conn.recv()
              if cmd != 'OK':
                  LOG.error("Failed to authenticate to %s port %s: %s" %
                            (self.host, self.port, payload[0]))
                  self.close()
          except Exception:
              exc_type, exc_value, exc_tb = sys.exc_info()
  
              # Log the error
              if exc_type == ValueError:
                  LOG.error("Received bogus response from server: %s" %
                            str(exc_value))
              elif exc_type == ConnectionClosed:
                  LOG.error("%s while authenticating to server" %
                            str(exc_value))
              else:
                  LOG.exception("Failed to authenticate to server")
  
              # Close the connection
              self.close()
  
              # Re-raise the exception
              raise exc_type, exc_value, exc_tb