![]() |
ICS 9.5 Problem TCPServer.DisconnectAll
Hallo,
bei einer kleinen Anwendung mit TCPIP Kommunikation möchte ich die Kommunikation sicher beenden, bevor ich das Programm beende. Ich habe eine TWSocketServer Komponente, die Verbindung zu einem remote client hat. Beim Aufruf von ServerSocket.DisconnectAll gibt es eine Exception. Wenn ich mit dem Debugger (vor der Exception) hineingehe, scheint der Grund auch klar zu sein. Hier ist der ICS Code :
Delphi-Quellcode:
DisconnectAll verwendet den ClientCount Wert, um Disconnect n Clients mal aufzurufen. Der ist in meinem Fall 1 und das bleibt er auch. Ich vermute, er sollte in der Disconnect Routine dekrementiert werden.
procedure TCustomWSocketServer.Disconnect(Client: TWSocketClient; ErrCode: Integer = WSAECONNABORTED); { V9.4 added ErrorCode }
var Msg : TMessage; PIdRec : PClientIdRec; begin FillChar(Msg, SizeOf(Msg), 0); { angus V7.00 pass CliId to WMClientClosed so correct client is closed } try New(PIdRec); PIdRec^.PClient := Client; PIdRec^.CliId := Client.CliId; Msg.WParam := ErrCode; Msg.LParam := LPARAM(PIdRec); WMClientClosed(Msg); // don't send message since called by DisconnectAll and expect immediate response except end; end; {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} procedure TCustomWSocketServer.DisconnectAll; { angus V6.01 } begin while [COLOR="Red"]ClientCount > 0[/COLOR] do Disconnect(Client[0], WSAECONNABORTED); { V9.4 added ErrorCode } end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:17 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz