Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8527841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:40:15+00:00 2026-06-11T08:40:15+00:00

We have a web-server designed using select() that never really saw much load until

  • 0

We have a web-server designed using select() that never really saw much load until last week and always used to work fine for our 500-1000 conn/s load. However, we recently started seeing much higher load (and spikes) and ran into the issue of select() going crazy after seeing a socket handle > FD_SETSIZE. This would just freeze up the server with select going into an unbreakable loop after timing out repeatedly if it had anything > FD_SETSIZE in its FD_SET. The option of switching to poll (or epoll) is not there right now and we have to stick with select. The way I fixed it for now is by increasing the listen queue and stop accepting new connections when I see a new one in return of accept() to be >= FD_SETSIZE and go back to select() on the listening socket. This works because the os recycles the file handles and always try to give the smallest available one. But the downside is I end up sending RST to some connections when calling accept() if the socket handle is >= FD_SETSIZE. This is still acceptable for now since it keeps the server running and connection drops are ~ 5%. Is there a way I can do it without dropping those connections. I don’t want to be keeping a count of all used handles and things which makes it too complicated. Is creating a bogus socket, checking its handle and closing it before calling accept will be fairly accurate estimation of what handle os is going to give me next.

while(max_conn_to_accept--){
SOCKET a_s = accept(..);
if(a_s >= FD_SETSIZE){
    close(a_s);
    return;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:40:17+00:00Added an answer on June 11, 2026 at 8:40 am

    Just raise FD_SETSIZE. Specify -DFD_SETSIZE=16384 on the compiler command line.

    I think your version is recent enough that there are no other issues. If you get an error in a header file, you may need to tweak a line or two.

    For example, if you see something like this:

    #undef __FD_SETSIZE
    #define __FD_SETSIZE    1024
    

    Change it to this:

    #undef __FD_SETSIZE
    #ifndef FD_SETSIZE
    #define __FD_SETSIZE    1024
    #else
    #define __FD_SETSIZE    FD_SETSIZE
    #endif
    

    Or if you see:

    #define FD_SETSIZE      1024
    

    Change it to:

    #ifndef FD_SETSIZE
    #define FD_SETSIZE      1024
    #endif
    

    But, again, I think you won’t need to change anything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an intranet web project that is currently using the IEWC tabstrip and
I have a web server which I do not know what the time zone
I have a web server located in Switzerland and it is intended to serve
I have a web server which is protected behind http-basic-auth. I've read through the
I have a web project working perfecly on my web server and on my
I would like to have a web server displaying the status of 2 of
Say I have a web page like this on an Ubuntu 12.04 web server
Can anyone explain if it is possible to have a web server for all
I have enabled the Web Server on my Mac OS X (10.5.6) by going
I currently have a single web server hosting multiple WordPress sites which use W3TC.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.