I think that the issue is because async_read
is "stream-oriented", see: Short reads and writes.
I assume that asio
is using CRLF
or LF
as the stream terminators in Windows and Linux respectively and I guess that somewhere it's using a Windows terminator for a Linux stream or vice-versa.
Try changing your async_read
call to:
mp_socket->async_read_some(boost::asio::buffer(mp_buffer, m_buffer_size),
boost::bind(&TcpSocket::m_handleRead, this,
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
I've used this method to read large binary files and verified the received files against their hash without any of the problems that you've encountered.