I\'m talking about speed limiting in download managers. For example, in Internet Download Manager there is a an option :
On Linux, I have no idea how it is done actually, but you could always look at the source code of applications doing this (eg wget
with --limit-rate
) or just strace
them to understand the involved system calls.
If I had to code a bandwidth limitation in a network application, I would simply do that after each buffer transmission: I would compute the current bandwidth, and would wait (without transmitting) the suitable delay to avoid overflowing the limitation.
On Linux, poll
and select
system calls can wait some delay till input or output is available. And to just wait, use usleep
or nanosleep
system calls, etc.