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 20:58:47

> That is not what your earlier code showed.

well, I don't understand you now. Maybe I'm explaining wrong.

I have this code and lets concentrate on it:

'mainfrm.pas'
procedure TMainForm.DiconBtnClick(Sender: TObject);
begin
   DisconnectServer;
end;

'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 press a button, it calls DisconnectServer(), then I get error :
'....raised exception class EIdClosedSocket with message Disconnected...'
There is no other way in the other part of code that this procedure can be
called because I have deleted possible calls to minimize possible  chance to
get this error. But even that I still get that message error.

This part of code which I showed earlier, doesn't have active call for
DisconnectServer() just for the time when I get the solution for that
occurring message.

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

I hope you can understand me now, do you need any other code? Where is the
bug that I'm getting still this message error?

s.

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive