Newsgroups : Borland : borland.public.delphi.internet.winsock : 2005 Aug : Second call to connect does not return
| Subject: | Second call to connect does not return |
| Posted by: | "keyser" (keyser_so..@usa.com) |
| Date: | 9 Aug 2005 11:51:57 |
Using Indy 9 and Delphi 7
I have a client/server set of apps and I make a connection on the
client, and then abruptly remove the server. (I kill it without
it sending any goodbye messages.) Here is the problem I see from
that point:
Short description:
I try to make a connection with a TidTCPClient connect() call. It fails with exception. I wait 10 seconds and try again.
This second call never returns, or causes an exception. Any ideas?
Long Description:
When I attempt a read or write on a connected socket and I
receive a disconnected exception, I start a timer for reconnect.
When it fires, I turn it off and call the retry routine. It will
reset the timer after a reconnect attempt and still not connected.
It always works one time through the loop but gets stuck in the
connect on the second attempt. Ideas? Here is the code:
Procedure DisconnectRetryTimerTimer( Sender:TObj);
begin
DisconnectRetryTimer.enabled := false;
retryConnect(True);
end;
procedure RetryConnect(auto: boolean);
begin
RemoteForm.RemoteClient.Host := edServerAddress.Text;
RemoteForm.RemoteClient.Port := StrToInt(edPort.text);
try
try
RemoteForm.RemoteUIClient.Connect();
finally
if not RemoteClient.Connected then
DisconnectRetryTimer.Enabled := true;
end;
except
if not auto then
WideMessageDlg('Remote Client can not start with Host as: '+^M^J+edServerAddress.text+' on port: '+edPort.Text,
mtError, [mbOK], 0);
end;
if not RemoteClient.Connected then
exit;
// Connection established
....
end;