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 8415343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:25:10+00:00 2026-06-10T01:25:10+00:00

I think that NFDS in select() determines how many sockets the function will check

  • 0

I think that NFDS in select() determines how many sockets the function will check in READFDS and the other fd_sets. So if we set 3 sockets in our fd_set, but I want to check only first one, I have to call select(1 + 1,…). Is this right?

Or does “nfds is the highest-numbered file descriptor in any of the three sets, plus 1” in linux select man means something different? Also why do we need to add + 1?

Example code – fixed

int CLIENTS[max_clients];//Clients sockets

int to_read;
FD_ZERO(&to_read);

int i;
int max_socket_fd = 0;

for (i = 0 ; i < max_clients ; i++)
{
 if(CLIENTS[i] < 0)
    continue;

 int client_socket = CLIENTS[i];
 if(client_socket > max_socket_fd)
    max_socket_fd = client_socket;
 FD_SET(client_socket , &to_read);
}

struct timeval wait;

wait.tv_sec = 0;
wait.tv_usec = 1000;

int select_ret = select(max_socket_fd + 1, &read_flags, NULL, NULL, &wait);
...
  • 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-10T01:25:12+00:00Added an answer on June 10, 2026 at 1:25 am

    “nfds is the highest-numbered file descriptor in any of the three sets, plus 1“

    Every file descriptor is represented by an integral value. So they are not asking for the x-th descriptor that you want to check, they are asking for the highest integral value of the descriptors in your READFDS +1.

    Btw, you should check out poll(2) and ppoll(2).

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

Sidebar

Related Questions

I think that (the title) is the problem I am having. I set up
Think that I have many activities,and all I want is this: I have a
I think that my problem is very stupid... My function doesn't return a decimal
I think that here answer will come from experience. I am right know wondering
i think that i have a sintax error in this code <script type=text/javascript> $(document).ready(function()
I think that we can specify or import our properties that we wish to
I think that a function called phpinfo is a function displaying environment of PHP,
I think that you can set like on post and get methods in jquery
Intuitively I'd think that if I want to find the best set of parameters,
I think that handlers in android are tools to get different objects that are

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.