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

  • Thread starter Thread starter zeion
  • Start date Start date
AI Thread Summary
The issue arises from the server continuously detecting activity from a client due to select() returning the same file descriptor (fd) repeatedly. This happens because the server does not read all available data from the client, leading to persistent notifications of activity. To resolve this, it is essential to ensure that the server reads all incoming data from the client’s fd before the next iteration of select(). Simply removing the client fd from the fd list or using fflush is ineffective in this scenario. Properly handling the data read will prevent the server from spamming the client with response messages.
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.
 
Technology 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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top