void TCPServer::handle_accept(TCPConnection::pointer new_connection, const boost::system::error_code& error) { if (!error) { new_connection->start(); connections.push_back(new_connection); start_accept(); } }
void TcpServer::handle_accept(TcpConnection::pointer new_connection, const boost::system::error_code& error) { if (!error) { connectionVector.push_back(new_connection); new_connection->start( connectionVector); } start_accept(); }
void handle_connect(const boost::system::error_code &err, tcp::resolver::iterator endpoint_itr) { if (!err) { conn->start(); conn->doOnMessageReceived(boost::bind(&client::process_message, this, _1)); } else if (endpoint_itr != tcp::resolver::iterator()) { // the connection failed - try the next one tcp::endpoint endpoint = *endpoint_itr; conn->getSocket()->async_connect(endpoint, boost::bind(&client::handle_connect, this, boost::asio::placeholders::error, ++endpoint_itr)); } else { std::cout << "Error: " << err.message() << "\n"; } }