select

Hi,

I’m having problem with select routine.

I’m adding multiple sockets and starting to select, I see that the last
socket added by FD_SET is only selected and other’s don’t work. I must be
missing something. OTOH, I didn’t find anything wrong with my code. It’s
very plain code:

  1. FD_ZERO
  2. open sockets
  3. FD_SET
  4. readyfds = select(width, &rfd, 0, 0, NULL);

I set the fd width properly (even tried FD_SETSIZE).

Any idead why only last socket will be selected, currently I’m testing only
2 sockets.

Thanks,
Hakim

Actually the sequence is as following:

  1. FD_ZERO
  2. open sockets
  3. send some data to all sockets (the other end will reply for these data
    received)
  4. FD_SET
  5. readyfds = select(width, &rfd, 0, 0, NULL);

Hakim


“Hakim” <ddrv2002@yahoo.ca> wrote in message
news:dardgc$52p$1@inn.qnx.com

Hi,

I’m having problem with select routine.

I’m adding multiple sockets and starting to select, I see that the last
socket added by FD_SET is only selected and other’s don’t work. I must be
missing something. OTOH, I didn’t find anything wrong with my code. It’s
very plain code:

  1. FD_ZERO
  2. open sockets
  3. FD_SET
  4. readyfds = select(width, &rfd, 0, 0, NULL);

I set the fd width properly (even tried FD_SETSIZE).

Any idead why only last socket will be selected, currently I’m testing
only 2 sockets.

Thanks,
Hakim

“Hakim” <ddrv2002@yahoo.ca> wrote in message
news:datr2q$svj$1@inn.qnx.com

Actually the sequence is as following:

  1. FD_ZERO
  2. open sockets
  3. send some data to all sockets (the other end will reply for these data
    received)
  4. FD_SET
  5. readyfds = select(width, &rfd, 0, 0, NULL);

What is width set to

Hakim


“Hakim” <> ddrv2002@yahoo.ca> > wrote in message
news:dardgc$52p$> 1@inn.qnx.com> …
Hi,

I’m having problem with select routine.

I’m adding multiple sockets and starting to select, I see that the last
socket added by FD_SET is only selected and other’s don’t work. I must be
missing something. OTOH, I didn’t find anything wrong with my code. It’s
very plain code:

  1. FD_ZERO
  2. open sockets
  3. FD_SET
  4. readyfds = select(width, &rfd, 0, 0, NULL);

I set the fd width properly (even tried FD_SETSIZE).

Any idead why only last socket will be selected, currently I’m testing
only 2 sockets.

Thanks,
Hakim

width = 1; //initial value
width = 1 + max(new fd + (wdith -1))

I also tried width=FD_SETSIZE.

Hakim

“Mario Charest” postmaster@127.0.0.1 wrote in message
news:datstl$us$1@inn.qnx.com

“Hakim” <> ddrv2002@yahoo.ca> > wrote in message
news:datr2q$svj$> 1@inn.qnx.com> …
Actually the sequence is as following:

  1. FD_ZERO
  2. open sockets
  3. send some data to all sockets (the other end will reply for these data
    received)
  4. FD_SET
  5. readyfds = select(width, &rfd, 0, 0, NULL);

What is width set to


Hakim


“Hakim” <> ddrv2002@yahoo.ca> > wrote in message
news:dardgc$52p$> 1@inn.qnx.com> …
Hi,

I’m having problem with select routine.

I’m adding multiple sockets and starting to select, I see that the last
socket added by FD_SET is only selected and other’s don’t work. I must
be missing something. OTOH, I didn’t find anything wrong with my code.
It’s very plain code:

  1. FD_ZERO
  2. open sockets
  3. FD_SET
  4. readyfds = select(width, &rfd, 0, 0, NULL);

I set the fd width properly (even tried FD_SETSIZE).

Any idead why only last socket will be selected, currently I’m testing
only 2 sockets.

Thanks,
Hakim

\

I made a typo.

width = 1 + max(new fd , (wdith -1))


“Hakim” <ddrv2002@yahoo.ca> wrote in message
news:dattdr$19r$1@inn.qnx.com

width = 1; //initial value
width = 1 + max(new fd + (wdith -1))

I also tried width=FD_SETSIZE.

Hakim

“Mario Charest” postmaster@127.0.0.1 wrote in message
news:datstl$us$> 1@inn.qnx.com> …


“Hakim” <> ddrv2002@yahoo.ca> > wrote in message
news:datr2q$svj$> 1@inn.qnx.com> …
Actually the sequence is as following:

  1. FD_ZERO
  2. open sockets
  3. send some data to all sockets (the other end will reply for these
    data received)
  4. FD_SET
  5. readyfds = select(width, &rfd, 0, 0, NULL);

What is width set to


Hakim


“Hakim” <> ddrv2002@yahoo.ca> > wrote in message
news:dardgc$52p$> 1@inn.qnx.com> …
Hi,

I’m having problem with select routine.

I’m adding multiple sockets and starting to select, I see that the last
socket added by FD_SET is only selected and other’s don’t work. I must
be missing something. OTOH, I didn’t find anything wrong with my code.
It’s very plain code:

  1. FD_ZERO
  2. open sockets
  3. FD_SET
  4. readyfds = select(width, &rfd, 0, 0, NULL);

I set the fd width properly (even tried FD_SETSIZE).

Any idead why only last socket will be selected, currently I’m testing
only 2 sockets.

Thanks,
Hakim



\

OK, I found the problem. With every select returns I need to put back all
fds by FD_SET, since select removes them from list those that are not ready.

Hakim.

“Hakim” <ddrv2002@yahoo.ca> wrote in message
news:datvam$2qc$1@inn.qnx.com

I made a typo.

width = 1 + max(new fd , (wdith -1))


“Hakim” <> ddrv2002@yahoo.ca> > wrote in message
news:dattdr$19r$> 1@inn.qnx.com> …
width = 1; //initial value
width = 1 + max(new fd + (wdith -1))

I also tried width=FD_SETSIZE.

Hakim

“Mario Charest” postmaster@127.0.0.1 wrote in message
news:datstl$us$> 1@inn.qnx.com> …


“Hakim” <> ddrv2002@yahoo.ca> > wrote in message
news:datr2q$svj$> 1@inn.qnx.com> …
Actually the sequence is as following:

  1. FD_ZERO
  2. open sockets
  3. send some data to all sockets (the other end will reply for these
    data received)
  4. FD_SET
  5. readyfds = select(width, &rfd, 0, 0, NULL);

What is width set to


Hakim


“Hakim” <> ddrv2002@yahoo.ca> > wrote in message
news:dardgc$52p$> 1@inn.qnx.com> …
Hi,

I’m having problem with select routine.

I’m adding multiple sockets and starting to select, I see that the
last socket added by FD_SET is only selected and other’s don’t work. I
must be missing something. OTOH, I didn’t find anything wrong with my
code. It’s very plain code:

  1. FD_ZERO
  2. open sockets
  3. FD_SET
  4. readyfds = select(width, &rfd, 0, 0, NULL);

I set the fd width properly (even tried FD_SETSIZE).

Any idead why only last socket will be selected, currently I’m testing
only 2 sockets.

Thanks,
Hakim





\

Hakim <ddrv2002@yahoo.ca> wrote:

OK, I found the problem. With every select returns I need to put back all
fds by FD_SET, since select removes them from list those that are not ready.

Yup. It has to – since you test each fd in readfds to see whether/not
they are set.

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com