예제 #1
0
	void seedArm_service_impl::closeSocket(connection::ptr spConn)
	{
		boost::weak_ptr<connection> wp = spConn;
		if (!wp.expired() && wp.lock() != nullptr)
		{
			try {
				boost::system::error_code ec_;
				spConn->socket().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec_);

				if(!ec_ && spConn->get_status() == connection::status::closing)
				{
					spConn->set_status(connection::status::close);
					_receiver.onClose(spConn);
				}
				else
				{
					std::cout << "status check : " << ec_.message().data() << std::endl;
				}
			}catch(std::exception e) {
				std::cout << "exception in seedArm_service_impl::closeSocket() => " << e.what() << std::endl;
			}
		}
		else
		{
			std::cout << "seedArm_service_impl::closeSocket(). already expired" << std::endl;
		}
	}
예제 #2
0
void Server::start()
{
    std::cout << "Starting server..." << std::endl;
    _status = AVAILABLE;

    Connection::ptr newConnect = Connection::new_( *this );
    _acceptor.async_accept( newConnect->socket(),
    boost::bind( &Server::handleAccept, this, newConnect, _1 ) );
}
예제 #3
0
void Server::handleAccept( Connection::ptr connect, const boost::system::error_code& err )
{
    std::cout << "Handling accept..." << std::endl;
    connect->start();

	Connection::ptr newConnect = Connection::new_( *this );
	_acceptor.async_accept( newConnect->socket(),
    boost::bind( &Server::handleAccept, this, newConnect, _1 ) );
}