Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Dec : Re: how to check connection?

www.cryer.info
Managed Newsgroup Archive

Re: how to check connection?

Subject:Re: how to check connection?
Posted by:"soonic" (xxsoon..@op.pl)
Date:Wed, 2 Jan 2008 22:52:45

>But if it is happening inside the thread instead, then that is perfectly
>normal behavior since that socket is closed when the server is deactivated
>but the thread is still trying to use it.
>

OK! When I run exe file it works fine. Just when I run through delphi, the
debugger shows that message.

So, lets get back to the point of my post. (I'm sorry for this little
confusion I made).

I get this message error in Delphi and my application freezes when I run it
from exe file when:


'netunit.pas'
procedure DisconnectServer;
begin
  with MainForm do
  begin
     if IdTCPServer.Active then IdTCPServer.Active := False;
    ....
   end;

   if ReadingThread <> nil then
   begin
     ReadingThread.Terminate;
     try
       MainForm.IdTCPClient.Disconnect;
     finally
       ReadingThread.WaitFor;
       FreeAndNil(ReadingThread);
     end;
   end;
end;

I get error message when I add here call for DisconnectServer():

procedure TReadingThread.Execute;
begin
  try
    while (not Terminated) and FConn.Connected do
    begin
      FData.ReadFrom(FConn);
      if not Terminated then Synchronize(UpdateGrid);
    end;
  except
    DisconnectServer;         <<<<<
  end;
end;

This way I can catch when the line is broken (network breaks). How to fix
it? It calls when it's already broken. It freezes, I want the application to
be working and be able to Activate Server when the network works again.

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive