楼上说的有道理,处理方式如下: pStream := TWinSocketStream.Create(ClientSocket,60000); try while (not Terminated) and ClientSocket.Connected do begin try Buffer := AllocMem(ReadLen); if pStream.WaitForData(500) then begin {...... 一大堆处理过程 .......} end else begin {超时的情况} {...... 一大堆处理过程 .......} end;
pStream := TWinSocketStream.Create(ClientSocket,60000);
try
while (not Terminated) and ClientSocket.Connected do
begin
try
Buffer := AllocMem(ReadLen);
if pStream.WaitForData(500) then
begin
{...... 一大堆处理过程 .......}
end else
begin {超时的情况}
{...... 一大堆处理过程 .......}
end;