indy采用的是阻塞模式,如果Server端未返回信息,这个readln会一直等下去,哪个TimeOut不起作用,是个BUG。
后来INDY团队给出的解决办法如下:
第一种:
Change this in last portion of ReadFromStack():
...
until (LByteCount <> 0) or (Connected = False);
...
to:
...
until (LByteCount <> 0) or (Connected = False) or (Result
= -1);
...
第二种:
Current faulty situation in ReadFromStack() at Line 427
(Beta 9.0.3-B):
...
// Timeout
if ARaiseExceptionOnTimeout then begin
raise EIdReadTimeout.Create(RSReadTimeout);
end;
Result := -1;
...
Change this to:
...
// Timeout
Result := -1; // MOVED!
if ARaiseExceptionOnTimeout then begin
raise EIdReadTimeout.Create(RSReadTimeout);
end else // ADDED!
break; // ADDED!
...