Boost logo

Boost Users :

From: Christian Rössel (christian.roessel_at_[hidden])
Date: 2006-10-18 12:39:25


Dear all,

I want to receive a boost::archive::text_iarchive using the
boost::asio::read_until () function.

  boost::asio::streambuf response;
  boost::asio::read_until(socket, response, boost::regex("\r\n"));
  std::istream responseStream(&response);
  boost::archive::text_iarchive responseArchive (responseStream);
  responseArchive >> retVal;

The data is sent using code linke this:

  boost::asio::streambuf response;
  std::ostream commandStream (&response);
  boost::archive::text_oarchive responseArchive (commandStream);
  const ReturnValue retVal (42);
  responseArchive << retVal;
  boost::asio::write(socket, response);

If I use boost::regex("\r\n") or a character that does not occur in the
sent archive, read_until throws an eof exception. If I use a delimiter that
is contained in the archive, read_until succeeds and the streambuf does
contain the entire archive, not only up to the delimiter.

What is the correct way to read the entire archive without throwing an
exception?

Thanks and regards,
Christian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net