J
Jeremy S. Richardson
Background:
I have a Legacy C++ application that sends binary data over a TCP
socket. Currently it's talking to a Perl script under Linux.
However, there's a need to port the receving application to Windows.
I rewrote the Perl script receiver as a .Net application in C#.
Problem:
The C# receiver fails to read the last few thousand bytes of data on 1
out of 10 transfers. There is a "socket closed by remote host"
exception on NetworkStream.EndRead().
Other Info:
I can confirm that the Legacy sender application sends all the data
before closing the socket. I'm transferring 1-10MB, and the failure
always happens when there are fewer bytes to transfer than the size of
buffer being used in the receiving application: with an 8K buffer, the
failure will happen with < 8K of data left.
The issue is not consistent. I haven't found any pattern to it.
Sometimes data will go through, but when I send the data again, it
fails. It also never fails this way with the old Perl script receiver
under Linux.
.... The socket shouldn't close on the receiver's end with data pending
to be read. Any ideas?
-Jeremy
I have a Legacy C++ application that sends binary data over a TCP
socket. Currently it's talking to a Perl script under Linux.
However, there's a need to port the receving application to Windows.
I rewrote the Perl script receiver as a .Net application in C#.
Problem:
The C# receiver fails to read the last few thousand bytes of data on 1
out of 10 transfers. There is a "socket closed by remote host"
exception on NetworkStream.EndRead().
Other Info:
I can confirm that the Legacy sender application sends all the data
before closing the socket. I'm transferring 1-10MB, and the failure
always happens when there are fewer bytes to transfer than the size of
buffer being used in the receiving application: with an 8K buffer, the
failure will happen with < 8K of data left.
The issue is not consistent. I haven't found any pattern to it.
Sometimes data will go through, but when I send the data again, it
fails. It also never fails this way with the old Perl script receiver
under Linux.
.... The socket shouldn't close on the receiver's end with data pending
to be read. Any ideas?
-Jeremy