<div dir="ltr">I&#39;m new to boost, and I&#39;m wondering about the best / most efficient way to transfer a large dataset via boost::asio.<br><br>I&#39;ve retrieved a datasetfrom a database (Cassandra) and I&#39;m using boost asio to provide a network service that responds to queries.<br><br>So I have a client socket and a dataset.  I have to iterate the dataset, perform some simple formatting (e.g. csv, json, xml), then write it out to the client socket.  But there&#39;s a lot of data.  Perhaps gigabytes.<br><br>So my initial thoughts were the producer / consumer pattern - the producer writing to a streambuf and the consumer async_write-ing it out to the client&#39;s socket.<br><br>But I&#39;m not sure this is a good approach - I know that streambuf isn&#39;t threadsafe and so managing the streambuf with locks may well become a performance bottleneck.<br><br>Obviously, I don&#39;t want to replicate what may be gigabyte(s) of data from a resultset into a buffer just so it can be written out to a socket, So should I write this data synchronously straight to the socket instead?  What&#39;s the best approach to solving this kind of problem?  <br><br>thanks for your consideration<br></div>