def ReceiveMessage(self):

        msg = ""
        while len(msg) < self.mHeaderSize:
            chunk = self.mSocket.recv(self.mHeaderSize - len(msg))
            if chunk == "":
                raise SocketException("connection broken")
            msg += chunk

        lmsg = string.atoi(msg)
        msg = ""

        while lmsg > 0:
            chunk = self.mSocket.recv(min(self.mBufferSize, lmsg))
            if chunk == "":
                raise SocketException("connection broken")
            msg += chunk
            lmsg -= len(chunk)

        return msg
receive arbitrary length message.
dataset/ETHPy150Open CGATOxford/cgat/obsolete/Sockets.py/Socket.ReceiveMessage