@classmethod
def ReceivePayload(cls, socket):
    '\n        Return only payload, not the raw message, None if failed.\n        socket: a blocking socket for read data.\n        '
    rbufsize = 0
    rfile = socket.makefile('rb', rbufsize)
    _L.debug('read raw_magic %s', threading.current_thread().name)
    try:
        raw_magic = rfile.read(4)
    except Exception as e:
        _L.debug('Fail to read raw_magic, %s', e)
        raw_magic = None
    _L.debug('read raw_magic %s done: %s', threading.current_thread().name, repr(raw_magic))
    if (not raw_magic):
        return None
    magic = struct.unpack(fmt, raw_magic)[0]
    if (magic != cls.magic):
        _L.error('Error: receive a malformat message, the message should start from a four bytes uint32 magic number')
        return None
    _L.debug('read payload')
    raw_payload_size = rfile.read(4)
    payload_size = struct.unpack('I', raw_payload_size)[0]
    _L.debug('Receive payload size %d', payload_size)
    payload = b''
    remain_size = payload_size
    while (remain_size > 0):
        data = rfile.read(remain_size)
        if (not data):
            return None
        payload += data
        bytes_read = len(data)
        assert (bytes_read <= remain_size)
        remain_size -= bytes_read
    rfile.close()
    return payload
Return only payload, not the raw message, None if failed.
socket: a blocking socket for read data.
@classmethod
def ReceivePayload(cls, socket):
    '\n        Return only payload, not the raw message, None if failed.\n        socket: a blocking socket for read data.\n        '
    rbufsize = 0
    rfile = socket.makefile('rb', rbufsize)
    _L.debug('read raw_magic %s', threading.current_thread().name)
    try:
        raw_magic = rfile.read(4)
    except Exception as e:
        _L.debug('Fail to read raw_magic, %s', e)
        raw_magic = None
    _L.debug('read raw_magic %s done: %s', threading.current_thread().name, repr(raw_magic))
    if (not raw_magic):
        return None
    magic = struct.unpack(fmt, raw_magic)[0]
    if (magic != cls.magic):
        _L.error('Error: receive a malformat message, the message should start from a four bytes uint32 magic number')
        return None
    _L.debug('read payload')
    raw_payload_size = rfile.read(4)
    payload_size = struct.unpack('I', raw_payload_size)[0]
    _L.debug('Receive payload size %d', payload_size)
    payload = b
    remain_size = payload_size
    while (remain_size > 0):
        data = rfile.read(remain_size)
        if (not data):
            return None
        payload += data
        bytes_read = len(data)
        assert (bytes_read <= remain_size)
        remain_size -= bytes_read
    rfile.close()
    return payload