Napisałem aplikację która odbiera komunikaty od klientów (IdTCPClient) podłączonych do serwera (IdTCPServer). Wykorzystałem INDY10. Serwer prawidłowo działa pobierając komunikaty od klientów. Teraz powstaje pytanie jak wysłać wiadomosć od serwera do klienta?

Kod serwera:

procedure TForm1.Button1Click(Sender: TObject);
begin
IdTcpServer1.Bindings.Add.IP:='127.0.0.1';
IdTcpServer1.Bindings.Add.Port:=3501;
try
IdTCPServer1.Active := true;
Memo1.Lines.Add('Uruchomiono');
except
Memo1.Lines.Add('Start error');
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
try
IdTCPServer1.Free;
Memo1.Lines.Add('Zatrzymano');
except
Memo1.Lines.Add('error');
end;
end;

procedure TForm1.IdTCPServer1Connect(AContext: TIdContext);
begin
Memo1.Lines.Add('Polaczenie od ' + AContext.Connection.Socket.Binding.PeerIP )
end;

procedure TForm1.IdTCPServer1Disconnect(AContext: TIdContext);
begin
Memo1.Lines.Add('Zerwano polaczenie od ' + AContext.Connection.Socket.Binding.PeerIP);
end;

procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var
wiadomosc:string;
begin
wiadomosc:=AContext.Connection.Socket.ReadLn;
Memo1.Lines.Add('Otrzymalo od ' +AContext.Connection.Socket.Binding.PeerIP + ' WIADOMOSC: ' + wiadomosc );
end;