Board index » delphi » How to handle clients that immediatly disconnect
Offir Bakshitz
![]() Delphi Developer |
How to handle clients that immediatly disconnect2005-01-17 09:29:30 PM delphi187 My application has a TIdTCPServer. I have to serve clients that immediatly close the connection after they receive the response from the server. Those clients do not wait for the socket that they created with the server to be closed by the server but rather close the socket them selves. The result is that I always get a EIdSocketError "Connection reset by peer". I guess that this happens because TIdTCPServer.DoExecute() checks the "connected" state of the connection after it calls the assigned OnExecute. Since my client always disconnects after the function that was assigned to OnExecute finishes, the call to "connected" always raises that execption. My problem is that I am not able to catch this execption. To solve this problem I thought about creating a TIdMyTCPServer that inherites from TIdTCPServer and to override the virtual DoExecute function so that it would not check the "connected" state after the call to OnExecute() and to have it return "false" to indicate that there is no additional work for this socket: function TIdMyTCPServer.DoExecute(AContext: TIdContext): Boolean; begin if Assigned(OnExecute) then OnExecute(AContext); result := false; end; Is this the correct way to address the problem? |