1024 Limitations of Linux under Select

Source: Internet
Author: User
1024 limit is not just the number of listeners, or the maximum value of the file descriptor, note that the value

Today, a mock client program is written to test and a select is used. The previous error is 1024 is the fd_set of the number of FD limit (my program is every time you select a FD, so I feel no problem), the result of the socket connection number reached 1050~1100, the total occurrence of a segment errors.

Look at the core file, repeatedly clear the process of thinking, can not find the problem point. What's even more puzzling is that by annotating part of the code (all of which are local variables), the resulting program becomes a segment error when the socket connection reaches about 1500.

Later thought to try is not a select problem, the simulation program does not call Select, all using blocked sockets, the results test to 10,000 socket connections are not a problem.

In the end, I see that the maximum value of the FD value in select is Fd_setsize (1024 in my environment), not the number.

There are also objections, such as a select for a value of 1025 for FD is no problem. I did not test it, but in my case, with a select of more than 1024 FD, the problem cannot be immediately exposed (I have been to 1500), but there may be

Issues such as cross-border access (segment fault).

Had not been thought of before, has always thought is similar to the ulimit limit has not changed. But the contradiction is the same configuration, with Poll/epoll write service end can test to more than 10K, now finally clear.

1024 Limitations of Linux under Select

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.