Link to home
Start Free TrialLog in
Avatar of dosware
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.
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

Go to Tools - Debugger options - Language Exceptions and uncheck the Stop on Delphi Exceptions checkbox
Avatar of dosware
dosware

ASKER

Thanks man, but I know it. I thought that it possible to use other TIdTcpClient function, not Disconnect :)
ASKER CERTIFIED SOLUTION
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dosware

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;
Avatar of dosware

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.
Avatar of dosware

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;
Avatar of dosware

ASKER

Unfortunately same errors
Avatar of dosware

ASKER

It normally works in EXE but I need to get normally working under Delphi also therefore in debug mode it looks terribly...