The listen parameter backlog of the socket function in linux

Source: Internet
Author: User
The parameter backlog of the listen in the socket function in linux has gone through some ups and downs. here we will summarize the parameter backlog of listen. PS: Server environment: ubuntu12.04. Client does not matter: I am macosx10.7. Let's take a look at $ manlisten. there is a paragraph in it: the parameter backlog of the listen in the socket function under the Ifthebackl... linux has gone through some ups and downs. Let's summarize the parameter backlog of listen. PS: Server environment: ubuntu12.04. Client does not matter: My mac OS x 10.7. Let's take a look at $ man listen, which contains a passage:
If the backlog argument is greater than the value in/proc/sys/net/core/somaxconn, then it www.2cto.com is silently truncated to that value; the default value in this file is 128. in kernelsbefore 2.4.25, this limit was a hard coded value, SOMAXCONN, with the value 128. $ sudo vi/proc/sys/net/core/somaxconn can be used to view the SOMAXCONN value of linux. my value is 128. It looks good to change it to 256... Upload another figure in unp Volume 1 (note: The following figure shows that the status of the unfinished connection queue should be SYN_RECV, which may be wrong ):

Okay. Now, Let's summarize the situation of my server calling listen: (note: Do not test on the same machine. I suspect that the same machine has not experienced three handshakes. When I ran the client and server programs at the same time under ubuntu12.04, I found that no matter how many backlogs are set, the "link queue completed" has been rising and has not stopped, "Link queue not completed" is always 0 .) when the value of backlog is <somaxconn, the number of connected queues that have been completed is the maximum value of backlog. The number of unfinished connection queues is about 10. When the value of backlog is greater than or equal to somaxconn, the maximum number of connected queues is somaxconn. The number of unfinished link queues is the same as the number of link queues. Conclusion: on ubuntu12.04, the value of backlog is the value of the connected queue. this value is limited by somaxconn. Finally, a script is provided to check the value of the two queues on the server (4333 in the script is the Port value of my server program ):#! /Bin/shecho "number of sockets in the ESTABLISHED connection queue" while ["1" = "1"] do www.2cto.com netstat-nat | grep ESTABLISHED | grep 4333 | wc-lsleep 2 done #! /Bin/shecho "number of sockets in the connection queue not established" while ["1" = "1"] donetstat-nat | grep SYN_RECV | grep 4333 | author of wc-lsleep 2 done xiaoyou is me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.