def connect(self, server, port=6667):
        """Connects to a given IRC server. After the connection is established, it calls
        the on_connect event handler.

        """
        self.socket.connect((server, port))
        self.lines = self._read_lines()
        for event_handler in list(self.on_connect):
            event_handler(self)