0

I would like to read some data from server. But I want to limit the receiving speed. What is the best way to do that?

Only solution that comes to my mind is to measure how many bytes I received in a certain period of time, calculate speed and then make a decision whether or not to continue reading from socket or to stop for some time.

But I think that it would lead to the fact that for the first part of certain period of time (in which I measure amount of bytes received) speed would tend to a maximum bandwidth and then drop to zero for the remaining part of the period. But I want it to be stable.

Stargateur
  • 24,473
  • 8
  • 65
  • 91
  • please tag only one language in your question unless it's necessary. – Stargateur Nov 13 '17 at 09:18
  • Whether you read it or not the data will come to your application if socket is established, unread data will be reported on read queue as displayed by netstat command – Pras Nov 13 '17 at 09:23
  • You could buffer and just send the max speed number of packets. – qwn Nov 13 '17 at 09:30
  • Yes, now I realize that I do not control receiving itself. Maybe one can control receiving speed through controlling a tcp window? Or could I just rely on the fact that after receive buffer is be full no data is sent by a server and I can control receive speed by read speed from a socket? – Maksim Sukhanov Nov 13 '17 at 10:15

0 Answers0