Wednesday, December 17, 2014

28232 and 64511

28232 is a magic number.
it is different between 32768 and 61000.
32768 and 61000 is usually the definition of /proc/sys/net/ipv4/ip_local_port_range

so the whole story is that when i wrote a tcp client, i found that the maximum connection the tcp client created is always 28232, so i searched this number in google and found the reason.

The work around is
check the current definition first,
> cat /proc/sys/net/ipv4/ip_local_port_range

Change the definition
> echo "net.ipv4.ip_local_port_range = 1024 65535" >> /etc/sysctl.conf
> sysctl -p

After this setting, the maximum connection created by a tcp client will be 64511 - another magic number.

Reference:
http://www.cnblogs.com/yoleung/articles/1288568.html

No comments: