sanchop22
sanchop22

Reputation: 2809

NetworkStream data is squeezed when a TCP client sends data heavily to a TCP server

I have a TCP server software in C#. I am reading data that is coming from a client by using the code below.

DataLen = NetworkStream.Read(Data, 0, Data.Length);

In this case, when a client sends data continuously with a very small period of time, new data comes while i am evaluating the last data buffer. What should i do in this case?

Upvotes: 0

Views: 176

Answers (1)

weismat
weismat

Reputation: 7411

The TCP protocol provides reliable, ordered delivery of a stream of bytes. Thus you do not need to worry about this.
The worst which can happen are requeues, when you are reading too slowly and the network buffers are too small. Thus you might need to split reading and processing into different threads.
The requeues are not transparent to the application, you will see just slowness and need tools like wireshark/tcpdump to detect them.

Upvotes: 1

Related Questions