This topic describes the syntax, description, parameters, return values, and examples of throttling functions.

limit_rate_after

This function is described as follows:
  • Syntax: limit_rate_after(n, unit)
  • Description

    You can call this function to set the initial amount after which the further transmission will be rate limited.

  • Parameters
    • n: the initial amount of data. Data type: integer. If you do not specify the unit parameter, the default unit is byte.
    • (Optional) unit: the unit to measure the data. Data type: char. Valid values for unit: K, M, and G. These values are case-insensitive.
  • Return values

    This function returns true upon a setting success and returns false upon a setting failure.

  • Examples
    limit_rate_after(10, 'k')                                                                                                                                                              
    limit_rate(1, 'm') 
    Note: Impose no speed limit on the first 10 KB and throttle the rest to 1 MB/s.

limit_rate

This function is described as follows:
  • Syntax: limit_rate(n, unit)
  • Description

    You can call this function to set the speed limit.

  • Parameters
    • n: the speed limit. Data type: integer. If you do not specify the unit parameter, the unit is byte per second.
    • (Optional) unit: the unit to measure the speed. Data type: char. Valid values of unit: K, M, and G. These values are case insensitive.
  • Return values

    This function returns true upon a setting success and returns false upon a setting failure.

  • Examples
    limit_rate_after(10, 'k')                                                                                                                                                              
    limit_rate(1, 'm') 
    Note: Impose no speed limit on the first 10 KB and throttle the rest to 1 MB/s.