Ejemplo n.º 1
0
    void do_write_some()
    {
        //auto self(this->shared_from_this());
        socket_.async_write_some(boost::asio::buffer(data_, packet_size_),
            [this](const boost::system::error_code & ec, std::size_t bytes_written)
            {
                if (!ec) {
                    // If get a circle of ping-pong, we count the query one time.
                    do_query_counter();

                    if ((uint32_t)bytes_written != packet_size_) {
                        std::cout << "asio_connection::do_write_some(): async_write(), bytes_written = "
                                  << bytes_written << " bytes." << std::endl;
                    }

                    do_read_some();
                }
                else {
                    // Write error log
                    std::cout << "asio_connection::do_write_some() - Error: (code = " << ec.value() << ") "
                              << ec.message().c_str() << std::endl;
                    stop(true);
                }
            }
        );
    }
	size_t read_some(const mutable_buffer &buffers, error_code &ec)
	{
		return do_read_some(buffers, ec);		
	}
	size_t read_some(const mutable_buffer &buffers) { return do_read_some(buffers); }