Article View: borland.public.cppbuilder.internet.socket
Article #2059Re: Would Indy's TIdTCPServer have any problem with connections I never read from?
From: Remy Lebeau (TeamB)
Date: Wed, 30 Aug 2006 19:22
Date: Wed, 30 Aug 2006 19:22
40 lines
2740 bytes
2740 bytes
"Lesley Anne" <mspfila-ng@yahoo.com> wrote in message news:44f5c67a$1@newsgroups.borland.com... > So, if the disconnect will be coming from the client's end of the > connection, is the best way to make sure the component recognizes > that disconect to periodically try to read from all connections, > trusting that they'll error out correctly when the connection is no > longer active? It is the only way to do it. Indy uses blocking sockets, and such sockets must be read from, or written to, in order to detect a graceful disconnect from the other party. > I thought at first that would be simple enough to do, but I'm having > a hard time finding how to even access all the (apparent) connections. Why just just read inside the server's OnExecute event? It is triggered on a per-connection basis. If you must access the connections via a list, then you can reach them through the server's Threads (Indy 9) or Contexts (Indy 10) property. > The best I could come up with to even see how many connections I > have is Server1->Bindings->Items->Collection->Count That is not correct. The Bindings collection contains the listening sockets that the server uses to accept incoming connections. The actual connections are kept tracked of separately. > How would you normally tell an application to do something with > each connection on a TIdTCPServer? You should be doing everything in the OnExecute event. But, if you must access one or more connections outside of that, then you must go through the server's Threads/Contexts property. By aware that TIdTCPServer is multi-threaded, so make sure your reading/writing is thread-safe. Gambit
Technical Details
Message-ID:
<44f5e682$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn12feed!worldnet.att.net!199.218.7.141!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<44f480ff@newsgroups.borland.com> <44f49d01$1@newsgroups.borland.com> <44f5c67a$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,c51ec25c5d4e68e1 X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <44f480ff@newsgroups.borland.com> <44f49d01$1@newsgroups.borland.com> <44f5c67a$1@newsgroups.borland.com> Subject: Re: Would Indy's TIdTCPServer have any problem with connections I never read from? Date: Wed, 30 Aug 2006 12:22:45 -0700 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <44f5e682$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1156966018 68.69.17.41 (30 Aug 2006 12:26:58 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn12feed!worldnet.att.net!199.218.7.141!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail