Esempio 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);
                }
            }
        );
    }
Esempio n. 2
0
 void do_write(ip::tcp::socket & sock, char * buff, size_t size) {
     if ( !started() ) return;
     sock.async_write_some(buffer(buff,size), 
                           MEM_FN3(on_write,ref(sock),_1,_2));
 }