dosware
asked on
Disconnected Exception
Hi All,
Can somebody tell me how can I turn off exception when TIdTcpClient is disconnecting? It always happen in Delphi only.
Thanks.
Can somebody tell me how can I turn off exception when TIdTcpClient is disconnecting? It always happen in Delphi only.
Thanks.
Go to Tools - Debugger options - Language Exceptions and uncheck the Stop on Delphi Exceptions checkbox
ASKER
Thanks man, but I know it. I thought that it possible to use other TIdTcpClient function, not Disconnect :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've read it, but can not find example how can I use it... Do you have any?
You can use it instead of DIsconnect
with TCPClient do
begin
Connect;
try
ListBox1.Items.Add(ReadLn) ;
finally
CheckForDisconnect(false);
end;
end;
with TCPClient do
begin
Connect;
try
ListBox1.Items.Add(ReadLn)
finally
CheckForDisconnect(false);
end;
end;
ASKER
I use this function for disconnect:
function StopSocket(ASocket: TIdTcpClient): Boolean;
begin
with(ASocket)do begin
try
if(Connected)then Disconnect;
finally
Result:=Connected;
end;
end;
end;
All sockets uses threads for reading information. When I'm trying to change the procedure Disconnect to procedure CheckForDisconnect it always freezes.
function StopSocket(ASocket: TIdTcpClient): Boolean;
begin
with(ASocket)do begin
try
if(Connected)then Disconnect;
finally
Result:=Connected;
end;
end;
end;
All sockets uses threads for reading information. When I'm trying to change the procedure Disconnect to procedure CheckForDisconnect it always freezes.
ASKER
Strange situation... Sometimes it tells me 'Not Connected' event but sometimes it tells me 'Disconnected' event... Strange!
OK so go to this way
function StopSocket(ASocket: TIdTcpClient): Boolean;
begin
with(ASocket)do begin
try
if(Connected)then
try
Disconnect;
except
//Get rid here of the exception
end;
finally
Result:=Connected;
end;
end;
end;
function StopSocket(ASocket: TIdTcpClient): Boolean;
begin
with(ASocket)do begin
try
if(Connected)then
try
Disconnect;
except
//Get rid here of the exception
end;
finally
Result:=Connected;
end;
end;
end;
ASKER
Unfortunately same errors
ASKER
It normally works in EXE but I need to get normally working under Delphi also therefore in debug mode it looks terribly...