예제 #1
0
	void Connection::run()
	{
		std::thread write_handler_thread(m_WriteHandler);

		async_read();

		m_Io.run();
		write_handler_thread.join();
	}
void connection::run()
{
	boost::thread write_handler_thread(m_write_handler);
	m_read_thread = boost::thread(boost::bind(&boost::asio::io_service::run, &m_io_service));

	while (alive()) {
		boost::asio::read_until(m_socket, m_buffer, "\r\n");

	    std::string line;
	    std::istream is(&m_buffer);
	    std::getline(is, line);
	    line = line.substr(0, line.length() - 1); //delete last character, i.e. \n
		m_read_handler(line);
	}

	write_handler_thread.join();
}