LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-06-2008, 05:27 AM   #1
RGummi
Member
 
Registered: Nov 2005
Posts: 90

Rep: Reputation: 15
select first parameter


Hello,

what should be used as the first parameter in a select statement (sockets)?
Should it FD_SETSIZE or filedescriptor + 1 ?

Code:
 
 fd_set fs;
 FD_ZERO(&fs);
 FD_SET(fdSocket, &fs);
or
Code:
 
 select(fdSocket+1, &fs, NULL, NULL, &tout);

Thanks
 
Old 09-06-2008, 05:42 AM   #2
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
The first parameter is the highest file descriptor plus one.
Beej example
FD_SETSIZE is an indication as to the possible maximum descriptors which can be contained in a set.
 
Old 09-06-2008, 06:07 AM   #3
RGummi
Member
 
Registered: Nov 2005
Posts: 90

Original Poster
Rep: Reputation: 15
Thanks,

here FD_SETSIZE is used

http://www.delorie.com/gnu/docs/glibc/libc_248.html

The select function checks only the first nfds file descriptors. The usual thing is to pass FD_SETSIZE as the value of this argument.
 
Old 09-06-2008, 08:01 AM   #4
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
I personally find it strange that it says "the usual thing" as I have never seen it used like that and man select shows
Quote:
...The first nfds descriptors are checked in
each set; i.e., the descriptors from 0 through nfds-1 in the descriptor
sets are examined. (Example: If you have set two file descriptors "4"
and "17", nfds should not be "2", but rather "17 + 1" or "18".)
 
Old 09-06-2008, 11:22 AM   #5
RGummi
Member
 
Registered: Nov 2005
Posts: 90

Original Poster
Rep: Reputation: 15
Hell,

This is the reason why I'am confused and posted this question.

RGummi
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux bash - how to use a dynamic parameter in shell parameter expansion expression nickleus Linux - General 2 08-21-2006 04:54 AM
Which parameter to use...? FrogGuy Linux - Hardware 2 11-19-2005 08:25 PM
how to look-over the parameter of module jiawj Slackware 3 05-10-2005 11:47 AM
Select() did not select my socket thvo Programming 1 05-08-2005 12:20 AM
Perl parameter dvong3 Programming 3 02-21-2004 10:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration