def close(self):
        """
        Close the connection.

        :param purge: If True (the default), the receive buffer will
                      be purged.
        """

        # Close the underlying socket
        if self._sock:
            with utils.ignore_except():
                self._sock.close()
            self._sock = None

        # Purge the message buffers
        self._recvbuf = []
        self._recvbuf_partial = ''