I'm using boost::asio to send some strings to a localhost client. The server accepts the connection with a TCP socket, and then simply sends some strings like so:
std::string message = ... + "\r\n";
boost::asio::write(m_socket, boost::asio::buffer(message));
That gets called quite a lot of times. I'm then receiving the data on the client via C#, in a relatively simple ReadLine loop:
public string Receive()
{
try
{
if(m_stream == null)
return string.Empty;
StreamReader reader = new StreamReader(m_stream, Encoding.ASCII);
string result = reader.ReadLine();
return result;
}
catch(Exception)
{
return null;
}
}
I have a thread that calls that function continuously until it returns null. Lazy, but it works. Almost.
A snip of the expected output (this is the server's record of what it's sending):
System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.PaintThemedButtonBackground : call count = 1
System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.PaintWorker : call count = 1
System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.PaintLayout : call count = 1
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.Paint : call count = 1
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.CreateTextFormatFlags : call count = 2
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.DrawFocus : call count = 1
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.DrawImage : call count = 1
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.DrawText : call count = 1
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.PaintField : call count = 1
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.CommonRender : call count = 1
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter..cctor : call count = 1
ColorOptions.Adjust255 : call count = 6
ColorOptions.Calculate : call count = 1
System.Windows.Forms.Button.CreateStandardAdapter : call count = 1
And the actual received of the same snip:
r.PaintThemedButtonBackground : call count = 1
CreateStandardAdapter : call count = 1
As you can see, I'm missing a few lines. I suck at networks, and I thought TCP was supposed to prevent this sort of thing happening. What did I screw up here?