   Boost buffer and multiple buffers
  Hi guys, I'm trying to marshall data into an asyncronous send call through Boost asio. I need to send two objects, one immediately after the other, so that it can be received on the other end in one call. I'm using TCP to keep things simple, though eventually I'll move to UDP because... well, you know.Anyways, my solution at the moment is to make a char * buffer large enough for both, and do 2 memcpy()s. It's fragile and stupid. I recall reading somewhere that boost can buffer multiple buffers into one buffer. Can I use that?What should I do?For example, I have right now:char *buffer=new char[sizeof(MessageHeader)+sizeof(ServerJoinOtherBody)];memcpy(buffer,&header,sizeof(MessageHeader));memcpy(buffer+sizeof(MessageHeader),b,sizeof(ServerJoinOtherBody));boost::asio::async_send(socket, boost::buffer(buffer, sizeof(MessageHeader)+sizeof(ServerJoinOtherBody), asyncHandler);   
  See Buffers and Scatter-Gather I/O.Put regular buffers into one of containers, boost::array is simplest for known number of elements. Buffers are constructed regularly, so they can be plain array.The underlying syscall will use scatter/gather, so there should be no inherent penalty for doing so, and might in theory be even slightly more efficient.   ;  There is no guarantee that the other end will receive the data in a single receive call anyway. It's TCP. It's a stream. Deal with it!;  If I use the scatter gather method described on that link (boost::array with boost::buffers) do I need to use an array with buffers to decode it? Or, in other words, will the TCP stream include extra data doing this?   ;Quote:will the TCP stream include extra data doing thisNo.   