Disconnected TCPServer thread won't terminate - Printable Version +- Atozed Forums (https://www.atozed.com/forums) +-- Forum: Indy (https://www.atozed.com/forums/forum-8.html) +--- Forum: Indy General Discussion (https://www.atozed.com/forums/forum-9.html) +--- Thread: Disconnected TCPServer thread won't terminate (/thread-2716.html) Pages:
1
2
|
RE: Disconnected TCPServer thread won't terminate - rlebeau - 04-25-2022 (04-19-2022, 06:36 PM)kbriggs Wrote: I moved the disconnect to OnConnect like this: Is there unread data left behind in AContext.Connection.IOHandler.InputBuffer? In between each call to OnExecute, the server checks the connection's Connected() method, and it should stop the thread once Connected() no longer returns True. However, Connected() will return True if there is unread data in the InputBuffer, even if the underlying socket is closed. Sometimes, when closing down a socket manually, you also need to clear the InputBuffer too, because of that reason. Try this: Code: if Key = '' then // invalid websocket header RE: Disconnected TCPServer thread won't terminate - kbriggs - 04-25-2022 (04-25-2022, 06:11 PM)rlebeau Wrote: I'll give that a try and report back. I didn't even check to see to what they were sending (if anything). Meanwhile, manually terminating the thread has been working great but if clearing the buffer works then I'll switch to that. RE: Disconnected TCPServer thread won't terminate - kbriggs - 04-26-2022 I can confirm that clearing the buffer after disconnecting does indeed terminate the thread. I had dozens of rogue connection attempts overnight and none of their threads were still active. |