Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Aug : When is .connected valid?

www.cryer.info
Managed Newsgroup Archive

When is .connected valid?

Subject:When is .connected valid?
Posted by:"keyser" (keyser_so..@usa.com)
Date:1 Aug 2005 10:45:02

using Indy 9 with Delpi 7:

I have the following code for thread execute:

while not Terminated do begin
  try
  if not conn.Connected then
    conn.Connect();

  // this will block until satisfied.
  msg := RemoteMessageType(conn.ReadInteger);

  ...
  // The above is blocked waiting for the server - I am
  // unplugging the network cable here to test the disconnection
  // logic below

  except
    on e: exception do begin
    // disconnect detected? The only thing we care about!
    if not conn.Connected then
          DisconnectNotice.ShowModal
    else
          DebugLog('Exception in TClientPollThread.Execute: '
                  +e.message);
      end;
    end;
  end;
//end code

My DisconnectNotice.ShowModal is never called but I get a zillion
messages in the debug log saying 'Socket Error # 10054.'
I could default to always assuming it is an exception due to
a disconnect but would prefer to be able to distinguish.  Why is
the connected value still true?  Would it eventually become
invalid if I let enough socket exceptions though?

Thanks.

Replies:

www.cryer.info
Managed Newsgroup Archive