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. --- telnetd.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 telnetd.cpp (limited to 'telnetd.cpp') diff --git a/telnetd.cpp b/telnetd.cpp new file mode 100644 index 0000000..9999d50 --- /dev/null +++ b/telnetd.cpp @@ -0,0 +1,19 @@ +#include "telnetd.h" + +#include + +telnet::Server::Server(boost::asio::io_service& io_service, const tcp::endpoint& endpoint) : acceptor_(io_service, endpoint) { + start_accept(); +} + +void telnet::Server::start_accept() { + Connection::p new_connection = Connection::p(new Connection(acceptor_.io_service())); + acceptor_.async_accept(new_connection->socket, boost::bind(&Server::handle_accept, this, new_connection, boost::asio::placeholders::error)); +} + +void telnet::Server::handle_accept(Connection::p new_connection, const boost::system::error_code& error) { + if(!error) { + new_connection->start(); + start_accept(); + } +} -- cgit v1.2.3