How to estimate the size of a byte array / buffer to read from NetworkStream?

int bufferSize = 8192;
Byte[] buffer = new Byte[bufferSize]; 

I need to read from NetworkStream, which will have a continuous stream of incoming data at high speed. I wanted to know

  • What should be the basis for setting the value bufferSize?
  • Is there a standard “safe” value that can be selected independently of enviornment?
  • Should it also change in the stream I'm trying to read (FileStream / NetworkStream / ..)?

Please consider performance as a focus point for evaluation.

+3
source share
1 answer

: , , .

1024, 4096 8192, , , .

0

Source: https://habr.com/ru/post/1780655/


All Articles