August 17th, 2004, 06:50 PM
timing my clients out
When a client connects to the server i've written, and no command is recieved from them for 30 seconds (the ideal time for testing, in practice it will be five minutes) they are disconnected. So here's the situation: My server console outputs "Client timed out blah blah blah", and i know that means the socket has been shutdown. However, the telnet instance that is the connection doesn't close right away. On occasion when i click on the telnet client, it immediately closes. On the other hand, sometimes i have to hit a key while its focused, and it closes in turn.
My question is, is this really disconnecting the client, or is the telnet instance still idle and connected to the server, and doesn't "realize" it's been cut off until it tries to send data, or something. The reason being, we're trying to destroy idle connections, so if they're going to still cling on to the server and stay idle, the job obviously isn't being done. Reasonably speaking, I'm assuming that they are in fact being connected, however I'd like a second opinion, because the fact the the telnet window doesn't close until you hit a keystroke raises the question.
Theres really no need to show any code, I'll just explain it to you. The sockets shutdown() method is called with an argument of 2, the sockets close method is called, then sys.exit() os called from inside so the thread should be dead. Then another thread which has an internal array of all of the clients threads periodically checks to see what threads are dead, and destroys their handle. So you see, there's really no reason why the connection should survive that...at all, I just need someone to confidently dispel this second guess ;)
August 18th, 2004, 02:08 PM
I suspect that this is a problem with the telnet client not realising that the connection has been closed, rather than your code.
The fact that telnet exits as soon as you hit a key indicates that the connection has been closed by your server, so I would not worry about it.
Dave - The Developers' Coach