I am trying to implement a Client/Server model using TCpClient
, with its Networkstream.Write()/Read()
functions sending/receiving a byte array.
It works most the time, except if I try to send three or more byte arrays in a row right after one another. The client says it sends them all, but the server only receives the first two.
Below is the code I use to write from client to server.
byte[] buffer = p.toByteArray(level);
stream.Write(buffer, 0, buffer.Length);
stream.Flush();
Is it consolidating them or something? I just don't understand how the server can receive distinct arrays when I send 2, but not 3 or more. If I separate the 3 writes, it works OK, but I really don't want to do that.
Any help would be much appreciated.
EDIT:
SOLVED :) Thanks for all your guys help. It was pushing 2-3 packets at a time, and my system was thinking 1 burst = 1 packet. I just rewrote my existing architecture with TCPClient to detect multiple packets :) Again, thanks for the help!