void client::login_handler(const boost::system::error_code& ec, std::size_t bytes_transferred)
{
if (ec)
{
error_.code = ec.value();
strncpy(error_.msg, ec.message().c_str(), ERROR_MSG_LEN - 1);
error_.msg[ERROR_MSG_LEN - 1] = '/0';
glog.error("login_handler get an error: %s", error_.msg);
return;
}
socket_.async_read_some(boost::asio::buffer(body_),
boost::bind(&client::login_handler, this, boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
static bool first = true;
if (first)
{
heartbeat_inteval_ = 10;
first = false;
send_heartbeat();
}
}
there is a deadline_timer to send heartbeat to server every 10 seconds , user the same socket_ .
i user asio handler tracking to debug, and found that sometimes between the async_read_some function call and their callback function call are more than 100ms, i don't kown why becasue the server send data always, and other commercial client is ok?
@asio|1445319300.343750|25*26|socket@00840104.async_receive
@asio|1445319300.343750|<25|
@asio|1445319300.390625|>26|ec=system:0,bytes_transferred=24605
@asio|1445319300.390625|26*27|socket@00840104.async_receive
@asio|1445319300.390625|<26|
@asio|1445319300.578125|>27|ec=system:0,bytes_transferred=15805
@asio|1445319300.593750|27*28|socket@00840104.async_receive
@asio|1445319300.593750|<27|
@asio|1445319300.781250|>28|ec=system:0,bytes_transferred=3939
@asio|1445319300.781250|28*29|socket@00840104.async_receive
@asio|1445319300.781250|<28|
@asio|1445319300.781250|>29|ec=system:0,bytes_transferred=8858
@asio|1445319300.796875|29*30|socket@00840104.async_receive
@asio|1445319300.796875|<29|
@asio|1445319300.796875|>30|ec=system:0,bytes_transferred=23906
@asio|1445319300.796875|30*31|socket@00840104.async_receive
@asio|1445319300.796875|<30|
@asio|1445319300.796875|>31|ec=system:0,bytes_transferred=25124
@asio|1445319300.796875|31*32|socket@00840104.async_receive
@asio|1445319300.796875|<31|
@asio|1445319300.921875|>32|ec=system:0,bytes_transferred=18061
@asio|1445319300.937500|32*33|socket@00840104.async_receive
@asio|1445319300.937500|<32|
@asio|1445319301.125000|>33|ec=system:0,bytes_transferred=19960
@asio|1445319301.125000|33*34|socket@00840104.async_receive
@asio|1445319301.140625|<33|
@asio|1445319301.140625|>34|ec=system:0,bytes_transferred=11680
could someone give some suggest? thanks a lot!