Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Aug 6, 2012 #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.
     
  2. jcsd
  3. Aug 7, 2012 #2

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: [C] select() won't stop responding to read from client
Loading...