Exemplo n.º 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;
		}
	}
Exemplo n.º 2
0
	void seedArm_service_impl::close(connection::ptr spConn)
	{
		spConn->set_status(connection::status::closing);

		_ios.post(
			_strand.wrap(boost::bind(
				&seedArm_service_impl::closeSocket
				, this
				, spConn)));
	}