Hi Again
I have now adjusted it to not take references to any temporary objects:
#include (buf.data()), boost::asio::buffer_cast return s;
}
private:
boost::asio::io_service io_service;
boost::asio::posix::stream_descriptor io_stream;
boost::asio::streambuf buf;
boost::optionalboost::system::error_code timer_result;
boost::optionalboost::system::error_code read_result;
};
int main(int argc, const char *argv[]) {
ReadWithTimeout xx;
for(int i = 0; i < 5; i++){
std::cout << i << " Type in 4 chareters and press enter" <<
std::endl << std::endl;
std::cout << "in> ";
std::cout.flush();
try {
std::cout << "out> " << xx.receive(5);
} catch (const std::exception & e) {
std::cout << e.what() << std::endl;
}
}
return 0;
}
But, I'm not sure whether this is a good idea, because I keep on
creating new async_read (things, objects??) how are they being cleaned
up?
--
Allan