Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Indy10 TCP Client Readln hangs
#1
Hi all

I'm using Indy10 TCP Client to communicate with a communication partner. 
To enable reading and writing at the same time I'm using IOHandler.ReadLn(Self.FETX, Self.FEncoding); inside the Execute of a TThread to read data.
And sending is done outside this Thread by the owner of the thread.

Problem is I sometimes (like every 5 - 10 Minutes) experience a hang on the IOHandler.ReadLn call which can last till I send data over the same TCPClient Instance.

Now I'm asking myself if there is a fundamental flaw in using a TCPClient like this?


Code:
procedure TReadingThread.Execute;
begin
 while not (Terminated) do
 begin
   try

      //Logged time here as start
     Self.FData := Self.FClient.IOHandler.ReadLn(Self.FETX,1000ms, -1, Self.FEncoding);
      //Logged time here as end
      //In case of "hang" this can take an infinite amount of time

     if (Self.FData <> '') and Assigned(Self.FOnData) then
     begin
       Synchronize(DataReceived);
     end;
   except
     on EIdException do
     begin
       ;
     end;
   end;
 Sleep(10);
 end;
end;




Code:
//Outside of TReadingThread, but same TCPClient Instance
Self.FTCPClient.IOHandler.WriteBufferOpen;
Self.FTCPClient.IOHandler.Write(Self.STX + Self.FSendDataBuffer + Self.ETX);
Self.FTCPClient.IOHandler.WriteBufferFlush;
Self.FTCPClient.IOHandler.WriteBufferClose;
Reply


Messages In This Thread
Indy10 TCP Client Readln hangs - by Attix22 - 07-20-2018, 07:15 AM
RE: Indy10 TCP Client Readln hangs - by rlebeau - 07-20-2018, 04:35 PM
RE: Indy10 TCP Client Readln hangs - by Attix22 - 07-23-2018, 07:00 AM
RE: Indy10 TCP Client Readln hangs - by kudzu - 07-23-2018, 03:10 PM
RE: Indy10 TCP Client Readln hangs - by Attix22 - 07-24-2018, 06:48 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)