multiple NetworkStream.Write intermittently only receives first one

curious issue I just dealt with, developing my own client/server

I set up my server to save all requests as .txt files, and banged on the client til I didn't get the expected response

with a bit of luck, I noticed the offending request cut off right after the header (I was issuing two NetworkStream.Write's … first for the header, then the rest)

when I combined these into one NetworkStream.Write, and banged on the client again, I couldn't replicate the error

on my server, I'm just …

BufferedStream s = new BufferedStream(TcpClient.GetStream(), TcpClient.ReceiveBufferSize); while (TcpClient.Available > 0) { s.Read(buffer, 0, buffer.Length); } 

anyone ever come across anything like this before?

I presume the way I've coded is correct, as it works fine most of the time, regardless of multiple NetworkStream.Write's … but I'm not sure if I'm missing something that might help ensure multiple NetworkStream.Write's don't ever fail?

by -biz-mark- via /r/csharp

Leave a Reply