-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtelnetserver.cpp
More file actions
29 lines (25 loc) · 807 Bytes
/
telnetserver.cpp
File metadata and controls
29 lines (25 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* Paweł Kapica, 334579
* Sieci Komputerowe
* Duże zadanie zaliczeniowe
*
*/
#include "telnetserver.h"
TelnetServer::TelnetServer(boost::asio::io_service& io_srv, uint16_t port, float_t time) : acceptor_(io_srv,
boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)), UI_REFRESH_TIME(time)
{
start_accept();
}
void TelnetServer::start_accept()
{
TCPConnection::ptr new_connection = TCPConnection::create(acceptor_.get_io_service(), UI_REFRESH_TIME);
acceptor_.async_accept(new_connection->socket(), boost::bind(&TelnetServer::handle_accept, this, new_connection,
boost::asio::placeholders::error));
}
void TelnetServer::handle_accept(TCPConnection::ptr new_connection, const boost::system::error_code& error)
{
if (!error) {
new_connection->start();
}
start_accept();
}