Network Programming C++ aria2 Network

Recompile aria2 to increment max connections per server

Edit a line of code and re-complie aria2 to unlock aria 2 connections limit

Posted by ntsd on February 9, 2020

There’s maximum 16 connection hard code in aria2 so when I want to split more connection I need to edit a line of code and recompile it

Edit max connections per server

Edit number arguments in NumberOptionHandler for MAX_CONNECTION_PER_SERVER in file “OptionHandlerFactory.cc”

from 16 to 64 the number is as you want.

OptionHandler* op(new NumberOptionHandler(PREF_MAX_CONNECTION_PER_SERVER,
                                              TEXT_MAX_CONNECTION_PER_SERVER,
                                              "1", 1, 64, 'x'));

Build the aria 2

Install following packages.

  • libxml2-dev
  • libcppunit-dev
  • autoconf (gettext)
  • automake
  • autotools-dev
  • autopoint
  • libtool

You can install by run this command.

brew install gettext automake autoconf libtool libxml2 cppunit

If you install LibXML with brew you also need to link it to /usr/local/include/.

sudo ln -s /usr/local/opt/libxml2/include/libxml2/libxml /usr/local/include/libxml

Add Gettext and libxml2 to your path for me it’s ~/.zshrc.

# gettext
export PATH=${PATH}:/usr/local/opt/gettext/bin

# libxml2
export PATH="/usr/local/opt/libxml2/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/libxml2/lib"
export CPPFLAGS="-I/usr/local/opt/libxml2/include"

Generate configs.

autoreconf -i

Run config you that you just create.

./configure

I’ll just using the default configuration.

If you want more details of it you can just copy steps from homebrew script here https://github.com/Homebrew/homebrew-core/blob/master/Formula/aria2.rb.

Generate make file.

make

Test all code (you can skip this step).

make check

Run make install to generate the binary file.

make install

Then you’ll get new aria2c binary file complied in /usr/local/bin/ directory.

You can check by the command.

ls -latr /usr/local/bin/

Test the compiled aria2 binary file

Make sure /usr/local/bin/ is in your path.

Now you can test the aria2c binary file that you just compile.

aria2c -k 1M -s 64 -x 64 http://ipv4.download.thinkbroadband.com/1GB.zip

Basic Options

-k, –min-split-size=<SIZE>

  • minimum split size

-s, –split=<N>

  • split file to N part

-x, –max-connection-per-server=<NUM>

  • maximum number connections to one server.

You’ll see the number of connections is 64.

the number of connections is 64

Done, Now you can use the binary file and unlock aria 2 connections limit.

references