def recv(self):
        if self._max_send_frag or self.__pending_recv:
            # _max_send_frag is checked because it's the same condition we checked
            # to decide whether to use write_andx() or send_trans() in send() above.
            if self.__pending_recv:
                self.__pending_recv -= 1
            return self.__smb_server.read_andx(self.__tid, self.__handle, max_size = self._max_recv_frag)
        else:
            s = self.__smb_server.recv_packet()
            if self.__smb_server.isValidAnswer(s,smb.SMB.SMB_COM_TRANSACTION):
                trans = smb.TRANSHeader(s.get_parameter_words(), s.get_buffer())
                data = trans.get_data()
                return data
            return None