From 0e7f2cef26bde782a5758b5e9a3dfe20f745df8f Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 31 Dec 2010 01:25:38 +0100 Subject: Added an echoing telnet server as a base for a telnet command interface. --- telnet_connection.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 telnet_connection.cpp (limited to 'telnet_connection.cpp') diff --git a/telnet_connection.cpp b/telnet_connection.cpp new file mode 100644 index 0000000..e2ea96f --- /dev/null +++ b/telnet_connection.cpp @@ -0,0 +1,15 @@ +#include "telnet_connection.h" + +#include + +telnet::Connection::Connection(boost::asio::io_service& io_service) : socket(io_service) { +} + +void telnet::Connection::handle_read(const boost::system::error_code& error, size_t bytes_transferred) { + boost::asio::write(socket, buf); +} + +void telnet::Connection::start() { + boost::asio::async_read_until(socket, buf, "\n", boost::bind(&Connection::handle_read, shared_from_this(), + boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); +} -- cgit v1.2.3