正常来说是这样的当客户端发送数据给服务器端后等待服务器端返回数据,但当时网络断开了了那客户端热行clientsocket.close就假死了 while not Terminated and form1.ClientSocket1.Socket.Connected do Begin
ddstr:=form1.clientsocket1.socket.ReceiveText();//程序已运行到这里
end;
ddstr:=form1.clientsocket1.socket.ReceiveText();//程序已运行到这里
end;
Stream : TWinSocketStream;
Buffer : array[0 .. 9] of Char;
begin
{ make sure connection is active }
while (not Terminated) and ClientSocket.Connected do
begin
try
Stream := TWinSocketStream.Create(ClientSocket, 60000);
try
FillChar(Buffer, 10, 0); { initialize the buffer }
{ give the client 60 seconds to start writing }
if Stream.WaitForData(60000) then begin
if Stream.Read(Buffer, 10) = 0 then { if can抰 read in 60 seconds }
ClientSocket.Close; { close the connection }
{ now process the request }
...
end
else
ClientSocket.Close; { if client doesn抰 start, close }
finally
Stream.Free;
end;
except
HandleException; end;
end;
end;