🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #4836

Re: Detecting a client disconnect

#4836
From: Paul Machiaverna
Date: Wed, 24 Nov 2004 14:55
50 lines
2721 bytes
Sorry about the last post.  Hitting TAB and Enter before it's time will do that!

The TIdTCPServer is dropped on a VCL TDataModule.  This is done to neaty package the server component with the event handler methods.  Namely, OnExecute.

In the OnExecute handler method, there is the following code (fragment)

while ( true )
{
  // If the socket is no longer connected,
  if ( !AThread->Connection->Connected() )
  {
    // Enter the shutdown sequence.
    break;
  }

  // If the communications with the client is complete
  // (as determined by the server via the data level
  // protocol),
  if ( ibComDone )
  {
    // Enter the shutdown sequence.
    break;
  }

  // Perform reads/writes.
  ...
}

The problem is that AThread->Connection->Connected() returns true when the client disconnects.  The client disconnects after a period of inactivity.  The server has its own inactivity timeout which will call DisconnnectSocket on the connection.

Other info:  INDY 9.0.14, WinXP Pro Version 2002 SP1

"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"Paul Machiaverna" <paul.machiaverna@i-stat.com> wrote in message
>news:41a3a222$1@newsgroups.borland.com...
>
>> I'm using INDY 9 components for a TCP server application.
>> Is there a way to detect when a client disconnects?
>
>TIdTCPServer already handles that for you.  If it is not working, then
>chances are your own code is preventing TIdTCPServer from doing its job
>properly.  Please show your actual code.  Also, which specific version of
>Indy 9 are you using, and which OS?
>
>
>Gambit
>
>
Technical Details
Message-ID: <41a4aed9$3@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41a3a222$1@newsgroups.borland.com> <41a3a429@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,2bbc0c2eefeb0788
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Paul Machiaverna" <paul.machiaverna@i-stat.com>
Sender: "Paul Machiaverna" <paul.machiaverna@i-stat.com>
Reply-To: "Paul Machiaverna" <paul.machiaverna@i-stat.com>
Subject: Re: Detecting a client disconnect
Newsgroups: borland.public.cppbuilder.internet.socket
X-User-Info: 130.36.11.140     
References: <41a3a222$1@newsgroups.borland.com> <41a3a429@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <41a4aed9$3@newsgroups.borland.com>
Date: 24 Nov 2004 07:55:05 -0700
X-Trace: newsgroups.borland.com 1101311705 207.105.83.66 (24 Nov 2004 07:55:05 -0700)
Lines: 51
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail