![]() |
TIdCmdTCPServer: Nachricht an Clients schicken
Ich nutze einen TIdCmdTCPServer in meiner Anwendung. Die Verbindung vom Client zum Server klappt recht gut. Jetzt möchte ich aber vom Server eine Nachricht (bzw. ein Kommando) an die Clients senden (z.B. das der Server heruntergefahren wird). Wie mache ich das? Die Indy-Doku ist an dieser Stelle ... sagen wir mal "dürftig".
Grüße |
Re: TIdCmdTCPServer: Nachricht an Clients schicken
Für alle Interessierten, so ist es machbar:
Delphi-Quellcode:
Der Client muss natürlich auf das Kommando reagieren und eine Antwort senden, sonst bleibt die Anwendung beim Warten auf die Antwort hängen.
procedure TServerForm.Button1Click(Sender: TObject);
var i: integer; ActContext: TIdContext; begin for i := TCPServer.Contexts.LockList.Count - 1 downto 0 do begin ActContext := TCPServer.Contexts.LockList.Items[i]; if ActContext.Connection.Connected then ActContext.Connection.SendCmd('test', [205]); ShowMessage(ActContext.Connection.LastCmdResult.FormattedReply.Text); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:45 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