You should call Shutdown to gracefully close the connection. If you want to call close, do it using an intermediate custom message. -- [EMAIL PROTECTED] Author of ICS (Internet Component Suite, freeware) Author of MidWare (Multi-tier framework, freeware) http://www.overbyte.be
----- Original Message ----- From: <[EMAIL PROTECTED]> To: <twsocket@elists.org> Sent: Wednesday, October 03, 2007 12:04 AM Subject: [twsocket] TWSocketThrdServer - Bogus OnDataAvailable triggeredwhen Closed. > Hello: > I'm using TWSocketThrdServer and processing > client data from within the OnDataAvailable event > handler (client is set to LineMode=True). I've > noticed that if the data transaction is completed and > I call Client.Close from within this event, the event > is called again with the previous ReceivedStr. > > Here's a sample of the code I am using: > > Procedure TMyServer.HandleDataAvailable(Sender: > TObject; Error: Word); > Var > DataStr: String; > bDone: Boolean; > Begin > If (Error = 0) Then Begin > With (Sender As TMyClient) Do Begin > DataStr := ReceiveStr; > > // parse the DataStr and do > // whatever needs to be done. > // bDone may be set here. > > If (bDone) Then Begin > SendLine('Sayonara.'); > TMyClient(Sender).Close; // <<-- HERE! > End; > End; > End Else Begin > // Handle errors... > TMyClient(Sender).Abort; > End; > End; > > When that Close method is called, the event is > immediately re-entered with the same data. Am I > doing something stupid? > > Thanks, > -dZ. > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be