summaryrefslogtreecommitdiff
path: root/telnetd.cpp
blob: 9129b8e929ed9894398fd05ca6524fcded609b9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "telnetd.h"

#include <boost/bind.hpp>

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_.get_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();
	}
}