发布网友 发布时间:2022-04-22 03:16
共1个回答
热心网友 时间:2024-01-12 02:09
void CTcpSrv::read_handler(const boost::system::error_code& error, std::size_t bytes_transferred)
{
if (!error)
{
#if DHAVE_CONFIG_H
printf("receive packet length is [%u]...\n", bytes_transferred);
#endif
//parse TCP packet
parse_tcp_packet(bytes_transferred);
//next read
memset(m_strBuffer, '\0', bytes_transferred);
m_socket.async_read_some(boost::asio::buffer(m_strBuffer, MAX_BUFFER_SIZE), \
boost::bind(&CTcpSrv::read_handler, shared_from_this(), \
boost::asio::placeholders::error, \
boost::asio::placeholders::bytes_transferred));
}
else
{
//An error occurred
std::cout<<"the connection was closed by the peer..."<<std::endl;
//g_client_manage_list->remove_client(shared_from_this());
}
}