Ejemplo n.º 1
0
void start_stdinput(boost::asio::io_service & io_service)
{
#if defined(BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR)
		boost::shared_ptr<boost::asio::posix::stream_descriptor> stdin(
			new boost::asio::posix::stream_descriptor( io_service, 0 )
		);
		boost::shared_ptr<boost::asio::streambuf> inputbuffer(
			new boost::asio::streambuf
		);
		boost::asio::async_read_until(
			*stdin, *inputbuffer, '\n',
			boost::bind(inputread , _1, _2, stdin, inputbuffer)
		);
#elif defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE)

		boost::shared_ptr<boost::asio::windows::object_handle>
			consolehandle(new boost::asio::windows::object_handle(io_service, GetStdHandle(STD_INPUT_HANDLE)));

		async_console_read_line(
			*consolehandle,
			boost::bind(&console_read, _1, consolehandle)
		);

#else
		boost::thread(
			boost::bind(input_thread, boost::ref(io_service))
		);
#endif
}
Ejemplo n.º 2
0
void start_stdinput(boost::asio::io_service & io_service)
{
#ifdef BOOST_ASIO_HAS_POSIX_STREAM_DESCRIPTOR
		boost::shared_ptr<boost::asio::posix::stream_descriptor> stdin(
			new boost::asio::posix::stream_descriptor( io_service, 0 )
		);
		boost::shared_ptr<boost::asio::streambuf> inputbuffer(
			new boost::asio::streambuf
		);
		boost::asio::async_read_until(
			*stdin, *inputbuffer, '\n',
			boost::bind(inputread , _1, _2, stdin, inputbuffer)
		);
#else
		boost::thread(
			boost::bind(input_thread, boost::ref(io_service))
		);
#endif
}