Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

When using NetworkStream, occasional corruption of data #11

Closed
GoogleCodeExporter opened this issue Mar 25, 2015 · 3 comments
Closed

When using NetworkStream, occasional corruption of data #11

GoogleCodeExporter opened this issue Mar 25, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1) Send data as fast as possible, insuring that the remote end checks the 
integrity of data
2) Once we reach the point where the local buffer is full and Udt::send cannot 
send the entire chunk, stream corrupts

What is the expected output? What do you see instead?
Basically the stream when reassembled on the other end has a multiple of 
1008-byte chunks missing

What version of the product are you using? On what operating system?
0.7.0.0 on Windows 7 and Windows XP

Please provide any additional information below.

I think this fixes the bug, we need to check to see if the entire chunk was 
written correctly:


void NetworkStream::Write(cli::array<System::Byte>^ buffer, int offset, int 
count)
{
    AssertNotDisposed();

    if (!CanWrite)
        throw gcnew NotSupportedException("Stream does not support writing.");
    int sent = 0;
    while (count > 0)
    {
        sent = _socket->Send(buffer, offset, count);
        count -= sent;
        offset += sent;
    }

}


Original issue reported on code.google.com by daniel.s...@googlemail.com on 6 Aug 2013 at 4:29

@GoogleCodeExporter
Copy link
Author

Good catch. I will get that fixed ASAP.

Original comment by cthomas7...@gmail.com on 6 Aug 2013 at 5:30

  • Changed state: Accepted
  • Added labels: Priority-High
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Author

This was resolved in v0.8.0.0, although in a slightly different manner than the 
example code. Udt::Socket::Send has been changed so that it blocks until the 
entire buffer is sent.

Original comment by cthomas7...@gmail.com on 7 Aug 2013 at 5:01

  • Changed state: Fixed
  • Added labels: 0.8.0.0
  • Removed labels: ****

@GoogleCodeExporter
Copy link
Author

Thanks - fix verified as working.

Original comment by daniel.s...@googlemail.com on 7 Aug 2013 at 9:35

  • Added labels: ****
  • Removed labels: ****

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant