Article View: borland.public.cppbuilder.internet.socket
Article #475Keep Alive & reconnecting
From: JohnG
Date: Wed, 27 Feb 2008 13:52
Date: Wed, 27 Feb 2008 13:52
64 lines
2472 bytes
2472 bytes
Hi,
I am using C++ Builder 2006 with indy 9 (9.0.50?) components.
I believe the "Keep Alive" code I have implemented in negatively
affecting the TIdTCPClients ability to reconnect to the
TidTCPServer. When a client reconnects prior to the server
realizing that the connection was severed, the client
disconnects immediately after reconnecting.
I believe (guess) that the Keep Alive code is in the process of
failing as the client is reconnecting. If I remove the Keep
Alive code, reconnections always succeeds. If I wait until the
server realizes that the connections have severed, reconnections
always succeed.
I have the following code in a TimerEvent ( every 10 seconds)
as my implementation of "Keep Alive" code between clients
(TidTCPClient) and server
//code to ping\keep alive to all connected clients
TList *list = IdTCPServer->Threads->LockList();
try
{
for( int i = 0 ; i < list->Count ; i++)
{
TIdPeerThread *thread = static_cast<TIdPeerThread*>(list->Items[i]);
if (thread->Connection->Socket->Connected())
{
strResponse = SendMessageToClient(thread,strPING,8000 /* timeout value*/);
}
else
{
//return faillure
}
}
}
catch(...)
{
IdTCPServer->Threads->UnlockList();
}
IdTCPServer->Threads->UnlockList();
//----------------------------------------------
The rest of my implementation is similar to this
http://tinyurl.com/2bq4vt
Any ideas or suggestions on how to prevent the keep alive code
from affecting cient reconnections will be greatly appreciated.
Regards,
JohnG
Technical Details
Message-ID:
<47c57942$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,137065672a0c16bb,start X-Google-Attributes: gid11508e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "JohnG" <whatis@email.com> Sender: "JohnG" <whatis@email.com> Reply-To: "JohnG" <whatis@email.com> Subject: Keep Alive & reconnecting Newsgroups: borland.public.cppbuilder.internet.socket X-User-Info: 138.11.0.153 X-Forwarded-For: unknown NNTP-Posting-Host: 207.105.83.66 Message-ID: <47c57942$1@newsgroups.borland.com> Date: 27 Feb 2008 06:52:50 -0700 X-Trace: newsgroups.borland.com 1204123970 207.105.83.66 (27 Feb 2008 06:52:50 -0700) Lines: 64 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail X-Original-Bytes: 2322