4

I have a problem, i use boost::asio for my server listener implementation, but using boost::asio when count connected sockets > 1000-1100 i have an error - "Too many opened files"

How can i fix that?

Thanks!

Breakdown
  • 1,035
  • 4
  • 16
  • 26
  • That is likely platform-specific (eg. you could be hitting a soft limit, or a hard system limit, or simply exhausting some resource). Please describe your platform (OS etc.) – Useless Jan 28 '13 at 16:06

1 Answers1

6

This isn't a boost::asio problem. This is an OS-level problem. Try doing ulimit -a on the command line and you'll see there's a limit for 'open files'. This is the number of file descriptors a process is allowed to own. It can be changed, but it's the reason you're getting the error.

This stack overflow question "How do I change the number of open files limit in Linux?" talks about how this limit can be changed. The short answer is that it's not particularly simple to do. It's an OS-level configuration parameter.

Community
  • 1
  • 1
Omnifarious
  • 54,333
  • 19
  • 131
  • 194
  • I am having the same problem with the client side. This is what is surprising to me. Because I'm only running at most 3 concurrent socket at a time but I still get "Too many files open error" when I try to create the 3. socket. I check the limit and it was 1024 files. Since this problem starts to occur around 6 hours later than client start time, I suspect I'm not actually destroying the socket obj after I'm done. But isn't is automatically get destroyed when gone out of scope? Because I'm not explicitly calling the destructor. – Akil Demir Jul 08 '20 at 07:52