title: Sending raw data over boost::asio
body: <p>i am attempting to send raw data over boost::asio, as boost::serialization is too slow for my needs. Following various examples and boost documentation, i have a client:</p>
  
  <p>SimulationClient:</p>
  
  <pre><code> void SimulationClient::sendData(std::vector&lt;WaveformDefinition&gt;waveformPackets) {
          socket.async_send_to(boost::asio::buffer(waveformPackets),
                  receiver_endpoint,
                  boost::bind(&amp;ClientEnvironmentEngine::sendComplete, this,
                          boost::asio::placeholders::error,
                          boost::asio::placeholders::bytes_transferred));
  }
  </code></pre>
  
  <p>I attempted Tanner Sansbury's solution below, but was unable to get it to work. However, I am having success using:</p>
  
  <pre><code>class WaveformReceiver {
       WaveformDefinition *buffer;
  
       WaveformReceiver(){
           buffer = new WaveformDefinition[MAX_WAVEFORMS];
           startReceive();
       }
  
       void startReceive() {
           socket_.async_receive_from(boost::asio::null_buffers(), remote_endpoint_,
                 boost::bind(&amp;WaveformReceiver::handleReceive, this,
                 boost::asio::placeholders::error,
                 boost::asio::placeholders::bytes_transferred));
       }
  
       void handleReceive(const boost::system::error_code&amp; error,
          std::size_t size/*bytes_transferred*/)
       {
            if (!error)
            {
                 int available = socket_.available();
                 int numWaveforms = available / sizeof(WaveformDefinition_c);
                 socket_.receive(boost::asio::buffer(buffer, available));
  
                 //copy buffer into another buffer so we can re-use the original buffer for the next read
                 WaveformDefinition_c* tempBuffer = new WaveformDefinition_c[numWaveforms];
                 std::memcpy ( tempBuffer, buffer, available );
  
                 //schedule a thread to handle the array of waveforms that we copied
                 threadPool.schedule( boost::bind( handleWaveforms, tempBuffer, numWaveforms));
                 //start listening for more waveforms
                 startReceive();
            }
       }
  }
  </code></pre>
  
  <p>Tanner, or others, can you tell me if what I am doing should also work, or if i am just getting lucky that it is currently working?</p>