Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Disconnected Exception

Posted on 2004-04-09
10
Medium Priority
?
582 Views
Last Modified: 2010-04-05
Hi All,

Can somebody tell me how can I turn off exception when TIdTcpClient is disconnecting? It always happen in Delphi only.

Thanks.
0
Comment
Question by:dosware
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 10790223
Go to Tools - Debugger options - Language Exceptions and uncheck the Stop on Delphi Exceptions checkbox
0
 

Author Comment

by:dosware
ID: 10790268
Thanks man, but I know it. I thought that it possible to use other TIdTcpClient function, not Disconnect :)
0
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 300 total points
ID: 10790295
OK, i've misunderstood the question....
So you can use CheckForDisconnect....

from Indy help

Determines if the peer has been disconnected.

procedure CheckForDisconnect(const ARaiseExceptionIfDisconnected: boolean = true; const AIgnoreBuffer: boolean = false); virtual;

Parameters

const ARaiseExceptionIfDisconnected: boolean = true

Raise an exception when the connection is closed. Default value is True.

const AIgnoreBuffer: boolean = false

Disregards the read buffer size. Default value is False.

Description

CheckForDisconnect is a procedure used to determine if a connection has been closed by either the server or the client.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dosware
ID: 10790321
I've read it, but can not find example how can I use it... Do you have any?
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 10790376
You can use it instead of DIsconnect

with TCPClient do
  begin
  Connect;
  try
  ListBox1.Items.Add(ReadLn);
  finally
  CheckForDisconnect(false);
  end;
  end;
0
 

Author Comment

by:dosware
ID: 10790401
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.
0
 

Author Comment

by:dosware
ID: 10790422
Strange situation... Sometimes it tells me 'Not Connected' event but sometimes it tells me 'Disconnected' event... Strange!
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 10790439
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;
0
 

Author Comment

by:dosware
ID: 10790455
Unfortunately same errors
0
 

Author Comment

by:dosware
ID: 10791175
It normally works in EXE but I need to get normally working under Delphi also therefore in debug mode it looks terribly...
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question