Quote Originally Posted by igmac View Post
Would it not be more efficient for the program to pass ownership of the buffer to the library rather than use the standard method of copying every single buffer? All this dual buffer stuff seems frightfully wasteful to me.
When it comes to network library, wouldn't it only need a pointer to data that you have in your application? Copying it over to librarys variable space is time consuming, but propably much much less time than it takes for it to move over network.

Much of the work regarding TCP buffers is done by the operating system. You don't necessarily need to do an extra layer yourself to encapsulate packets. TCP protocol guarantees that everything arrives in its destination in same order as you send, without loss.

If it works, it's ok. The less the data is moved around the better.