code: async def connect(self, hostname=None, port=None, reconnect=False, **kwargs):
          
          if (not hostname or not port) and not reconnect:
              raise ValueError('Have to specify hostname and port if not reconnecting.')
  
          # Disconnect from current connection.
          if self.connected:
              await self.disconnect(expected=True)
  
          # Reset attributes and connect.
          if not reconnect:
              self._reset_connection_attributes()
          await self._connect(hostname=hostname, port=port, reconnect=reconnect, **kwargs)
  
          # Set logger name.
          if self.server_tag:
              self.logger = logging.getLogger(self.__class__.__name__ + ':' + self.server_tag)
  
          self.eventloop.create_task(self.handle_forever())
docs: Connect to IRC server.