implements the recv msg.