david wrote:
> 
> Hello,
> 
>     Is it posssible to reuse the "struct fd_set"  in the call to
> select() ?
> ie :
>     - call FD_SET( ) one time for each fd
>     - call select() several times with the same "fd_set"
> 
> thanks in advance for your help

No.

The fd_set you get back from select() is only set on the
readable/writable/excepted file descriptors.

What you should do instead is something like this:

fd_set fd_input, fd_input_test;

FD_SET(0, fd_input);
while(condition){
        fd_input_test = fd_input;

        select(FDSETSIZE, fd_input_test, NULL, NULL, NULL);
        if(FD_ISSET(0, fd_input_test)

etc...

}

In other words, setup an fd_set how you want and keep "refilling" the
one you send to select().

In learning this issues (only last week!) I wrote myself a simple
irc-like server and client.  Total source lines: about 200.  I can send
it to anyone who is interested.

Reply via email to