posted 18 years ago
You're not handling whatever operation is available on the keys, so the next time you do select(), that operation is ready again. Removing the key from the selected set doesn't clear it's ready state, IIRC.
If you get a connection request operation, you must accept or deny it. If you get an I/O ready state, you must read or write appropriately.
Basically, each time through the outermost while loop the Selector is saying, "Some client is waiting to connect." That you tell the Selector that you got the message (removed the key from the selected set) doesn't change the fact that the client is still waiting to connect.