added a missing memcpy before the main loop, and merged the send + recv into a Sendrecv