troubleshooting Question

How do I recover from a 10054 error in BDS

Avatar of jetbet
jetbetFlag for New Zealand asked on
Delphi
1 Comment1 Solution629 ViewsLast Modified:
I have an application that uses IdTCPClient.

The problem is that the network can be a bit flakey and when I get a disconnect I get a 10054 error whenever I try to Connect, Disconnect or basically anything else to do with the socket.

The only way I can get going again is to restart my application. This is not acceptable behaviour for my customer. I understand that this is windows behaviour and behaves differently in a linux environment.

Does anyone have a work around so that I can recover without a restart.

I have included relevent code.

Thanks.
procedure TFR_Display_Main.GetRequestResponse();
begin
 IdTCPClient1.Host:=ED_JEQIIP.Text;
 IdTCPClient1.Port:=StrToIntDef( ED_JeqiPort.Text,0);
 
 if not IdTCPClient1.Connected then
     IdTCPClient1.Connect;
 
//  IdTCPClient1.Connect;
 
  IdTCPClient1.IOHandler.WriteLn(RequestMessage);
    while wait(300) do
    Application.ProcessMessages;
  try
    FResponseMessage := IdTCPClient1.IOHandler.ReadLn('</Response>');
    FResponseMessage:=ReplaceText(FResponseMessage,#13,'');
    FResponseMessage:=ReplaceText(FResponseMessage,#10,'');
    FResponseMessage:=FResponseMessage+'</Response>';
    IdTCPClient1.DisconnectNotifyPeer;
  except
 
  end;
end;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros