The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
retrieved multiple lines on multiple places in a file dala Shell Programming and Scripting 8 03-14-2008 03:28 PM
Awk - select from a list simha77777 UNIX for Dummies Questions & Answers 14 02-07-2008 12:42 PM
SED scripting select i_am_a_robot Shell Programming and Scripting 6 05-02-2007 07:00 AM
Dynamic select with multiple word menu items domivv Shell Programming and Scripting 5 07-22-2004 09:52 AM
how to select a value randomly norsk hedensk Shell Programming and Scripting 1 10-28-2003 05:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-13-2002
amatsaka amatsaka is offline
Registered User
  
 

Join Date: Mar 2002
Location: Greece
Posts: 14
Lightbulb Multiple fds in select()

Hi

I want to read messages from multiple interfaces using one select() statement. Does anybody knows if I can specify multiple fds in the *readfds parameter? If yes, what's the max num of fds?
Something like the following:


fd_set descrSet = {0};
int retVal;
MyStructS *msg = NULL;

while{
FD_ZERO(&descrSet);
FD_SET(Intf1SockNum, &descrSet);
FD_SET(Intf2SockNum, &descrSet);
FD_SET(Intf3SockNum, &descrSet);
.
.
FD_SET(IntfnSockNum, &descrSet);

/* wait for msg / timeout */
retVal = select(FD_SETSIZE, &descrSet, NULL, NULL, &timeout);

/*check what happened */
switch (retVal){
case -1:
/* handle error */
break;

case 0:
/* timeout before msg arrived */
break;

default:
if (FD_ISSET(Intf1SockNum, &descrSet)){
retVal = ReadMsgfromIntf1(&msg);
/* handle msg rxed*/
} /* if */
if (FD_ISSET(Intf2SockNum, &descrSet)){
retVal = ReadMsgfromIntf2(&msg);
/* handle msg rxed*/
} /* if */
.
.
if (FD_ISSET(IntfnSockNum, &descrSet)){
retVal = ReadMsgfromIntf3(&msg);
/* handle msg rxed*/
} /* if */
} /* switch*/
} /* while */

Thanx
  #2 (permalink)  
Old 11-13-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
Your limit will depend on how many fd's you can have open at once.

By default, those macros are setup to handle onle 2048 fd's. If you need more fd's than than, then you must define FD_SETSIZE to be the number that you need. Put this "define" above the the "include" which is bringing in the FD macros. That include file will see your definition and will respect it.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:48 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0