7#define RESIPROCATE_SUBSYSTEM ReTurnSubsystem::RETURN
19 asio::ip::tcp::endpoint
endpoint(address, port);
22 mAcceptor.set_option(asio::ip::tcp::acceptor::reuse_address(
true));
27 asio::ip::v6_only
v6_opt(
true);
28 mAcceptor.set_option(
v6_opt);
35 InfoLog(<<
"TcpServer started. Listening on " << address.to_string() <<
":" << port);
41 mAcceptor.async_accept(((
TcpConnection*)mNewConnection.get())->socket(), std::bind(&TcpServer::handleAccept,
this, std::placeholders::_1));
45TcpServer::handleAccept(
const asio::error_code&
e)
58 mNewConnection->stop();
61 mNewConnection.reset(
new TcpConnection(mIOService, mConnectionManager, mRequestHandler));
62 mAcceptor.async_accept(((TcpConnection*)mNewConnection.get())->socket(), std::bind(&TcpServer::handleAccept,
this, std::placeholders::_1));
66 ErrLog(<<
"Error in handleAccept: " <<
e.value() <<
"-" <<
e.message());
67 if(
e == asio::error::no_descriptors)
70 mNewConnection.reset(
new TcpConnection(mIOService, mConnectionManager, mRequestHandler));
71 mAcceptor.async_accept(((TcpConnection*)mNewConnection.get())->socket(), std::bind(&TcpServer::handleAccept,
this, std::placeholders::_1));
void start(ConnectionPtr c, const asio::ip::address &remoteAddress)
Add the specified connection, from remoteAddress, to the manager and start it - or,...
The common handler for all incoming requests.
Represents a single connection from a client.
TcpServer(const TcpServer &)=delete