Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 Nov : TCPServer Disconnection Error - Indy10
| Subject: | TCPServer Disconnection Error - Indy10 |
| Posted by: | "Bruno" (nospam@nospam.com) |
| Date: | Thu, 23 Nov 2006 05:26:43 |
Hello,
I try to use TCPServer and TCPClient, I make simple sample, get the code of
the server :
// Active TCPServer in listen mode
procedure TForm1.btActiveClick(Sender: TObject);
begin
idTCPServer1.DefaultPort := 1234;
idTCPServer1.Active := True;
end;
// Stop TCP Server
procedure TForm1.btStopClick(Sender: TObject);
var i : Integer;
ClientsList: TList;
begin
ClientsList := idTCPServer1.Contexts.LockList;
idTCPServer1.Contexts.UnlockList;
for i:= 0 to ClientsList.Count-1 do
TIdContext(ClientsList.Items[i]).Connection.Disconnect;
idTCPServer1.Active := False;
end;
// Clear Thread
procedure TForm1.IdTCPServer1Disconnect(AContext: TIdContext);
begin
AContext.Data := nil;
end;
// Show Data retrieve on Memo
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var Data : String;
begin
Data := Trim(AContext.Connection.IOHandler.ReadLn);
Memo1.Lines.Add(Data);
end;
When I click on btStop (to stop server), I have exception error
(EIdClosedSock with message 'Disconnected'),
Anyone can explain me, why please?
Thank you.