reading and writing the message buffer, get_next_message functionality