New Reply

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

 
Share Thread
Aug6-12, 04:37 PM   #1
 

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


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.
PhysOrg.com science news on PhysOrg.com

>> City-life changes blackbird personalities, study shows
>> Origins of 'The Hoff' crab revealed (w/ Video)
>> Older males make better fathers: Mature male beetles work harder, care less about female infidelity
Aug7-12, 02:12 AM   #2
 
Recognitions:
Gold Membership Gold Member
Science Advisor Science Advisor
Retired Staff Staff Emeritus
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.
New Reply

Similar discussions for: [C] select() won't stop responding to read from client
Thread Forum Replies
[C] How do I read a whole line from a client? Programming & Comp Sci 2
Responding what when someone calls you General Discussion 120
Stop Washington lobbyists (read legalized corruption) Current Events 36
No One Is Responding To My Posts!! General Discussion 27