[C] select() won't stop responding to read from client

  • Thread starter Thread starter zeion
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
zeion
Messages
455
Reaction score
1
Hi,

So I have written a server that will detect activity by connected clients using select. I am able to detect when a client has typed something from their keyboard, and then it will send send a message to the client in response.

The problem is that select() seems to be returning the same client fd in every iteration. So I would type one character from the client, then the server non-stop spams the client with the response message because it thinks that the client has still typed something.

How do I make it so that select() will only send the response message once and not forever?
I've already tried to remove client FD from the fd list and fflush but they don't do jack.
 
Physics news on Phys.org
Are you actually reading data from the fd, and all of it?

If not, then select is doing exactly what it's supposed to do: it's telling you there's data there to be read.