title: Sending/Recieving an binary_oarchive over asio tcp stream with libboost
body: <p>I'm coding for a robot which i need to have all robot's data in my computer while it's running for debug purposes. I have written a class named debug provider which has this responsibility. here is the code i written for this class:</p>
  
  <pre><code>void
  DebugProvider::doWork()
  {
          boost::asio::io_service io_service;
  
          tcp::endpoint endpoint(tcp::v4(), 10001);
          tcp::acceptor acceptor(io_service, endpoint);
  
          tcp::iostream stream;
          boost::system::error_code error;
          acceptor.accept(*stream.rdbuf(), error);
          if(!error)
          {
                  boost::archive::binary_oarchive oa(stream);
                  oa &lt;&lt; dataProvider;
          }
          usleep(50);
  }
  </code></pre>
  
  <p>doWork method is called every 50us in a boost::thread, and DataProvider contains all the data in the robot (like camera image, joints position, etc.).</p>
  
  <p>I also wrote a simple client which gets the data from robot and shows camera image in my laptop. (since I'm testing the code, it gets the data once).</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      DataProvider dp;
      tcp::iostream stream("10.1.1.1", "10001");
      boost::archive::binary_iarchive ia(stream);
      ia &gt;&gt; dp;
  
      Mat mat = dp.getCameraImage();
      imshow("camera", mat);
      waitKey();
  
     return 0;
  }
  </code></pre>
  
  <p>My problem is after running the program both in robot and computer. both programs throw an stream_error.</p>
  
  <p>I tried with telnet to get data from the server and everything works fine but with boost::asio::ip::tcp the described error throws.</p>