Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Socket buffer size dynamic

I develop a speed test software with a graph. Each seconds, i draw the throughput on the graph. I use socket with a loop on socket.read(...)

The problem is the buffer size. If i set the buffer to 32ko, when the speed is low, my graph is wrong (block on read function until the buffer isn't full). If i set the buffer to 512 octets, the speed is "flanged".

How to set dynamically the buffer size ?

like image 542
FinalSpirit Avatar asked Feb 28 '26 12:02

FinalSpirit


1 Answers

block on read function until the buffer isn't full

I don't know what that means. Socket reads don't attempt to fill the buffer, they wait until some data arrives and then move that into the buffer, whatever its length, up to the size of the buffer. The size of the buffer should have no effect when speeds are low. It will take effect when speeds are high.

like image 128
user207421 Avatar answered Mar 03 '26 02:03

user207421



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!