part of my app transfers a file from 1 computer to another across a network,
the client connects to the server and gets the size of the file,
the server then sends ( size/1024 ) full 1024 byte buffers to the client
followed by 1 ( size % 1024) buffer
on the same machine this works fine
but when i tried it across my lan it only worked in 1 direction, A to B but
B to A would result in the file being corrupt.
this is the send part for the full buffers:
for(int i = 0; i < fullBuffers; i++)
{
frStream.Read(sendBuffer, 0, Common.FTBufferSize);
connectedSock.Send(sendBuffer);
Quote:
}
so in an effort to find out where it was being corrupted, i added between
the read and send statements above, code to hash the buffer and display it
on the screen, this way i could see if both had the same data and identify
if it was a transmition error.
but this had the unexpected result of fixing the issue :-/
so i then replaced the hash with a sleep statement and this also fixed the
error:
for(int i = 0; i < fullBuffers; i++)
{
frStream.Read(sendBuffer, 0, Common.FTBufferSize);
System.Threading.Thread.Sleep(1);
connectedSock.Send(sendBuffer);
Quote:
}
But i dont know why...
Can anyone explane why this is happening?
and if there is a better solution or a better way of doing it?