title: Recv ring buffer vs simple buffer
body: <p>I'm working on a client-server app. My app is working with variable size packets, each packet has a header and a payload of variable length.</p>
  
  <p>My dilemma is what is the best approach for handing the packets when doing recv.
  Most of the tutorials I've came across suggest using a ring buffer but as far as I can tell it's more efficient to use a buffer whose size is twice the size of the biggest packet you can handle.</p>
  
  <p>If I use a ring buffer I need an additional buffer for recv and then I need to copy the buffer in the ring buffer which means I need to do one or two memcpys to insert the buffer in the ring buffer </p>
  
  <p>If I use the single buffer approach I only need one buffer which I can pass to recv call and a memmove call to move data to the start of the buffer when I got a full packet and there still is data belonging to another packet in the buffer.</p>
  
  <p>Am I getting something wrong ?</p>
  
  <p>PS. If you can point me to any source code/example where variable length packets are handled that would be helpful.</p>