正常来说是这样的当客户端发送数据给服务器端后等待服务器端返回数据,但当时网络断开了了那客户端热行clientsocket.close就假死了   while not Terminated and form1.ClientSocket1.Socket.Connected do   Begin
    ddstr:=form1.clientsocket1.socket.ReceiveText();//程序已运行到这里
end;

解决方案 »

  1.   

    GoldShield(金盾) ,,老大,,I  是不是该服了U前两天看您才两条库叉的
      

  2.   

    侃侃帮助怎做的,呵呵;TWinSocketStream is a stream that provides services which allow applications to read from or write to socket connections.UnitScktCompDescriptionUse TWinSocketStream to read or write information over a blocking socket connection. Windows socket objects include methods to read from or write to the socket connection they represent. However, these methods do not provide a mechanism for timing out when the socket connection is dropped or for waiting until the socket connection is ready before reading. When the socket is a non-blocking socket, this lack of a time-out or waiting mechanism is not a problem, because reading and writing occur asynchronously in response to notifications from the socket connection. For blocking sockets, however, these mechanisms provided by TWinSocketStream are necessary so that the application using the socket does not hang indefinitely.To use a Windows socket stream, create an instance of TWinSocketStream, use the methods of the stream to read or write the data, and then free the Windows socket stream.Note: TWinSocketStream does not work with non-blocking sockets.
      

  3.   

    The following example shows a typical ClientExecute method for a custom descendant of TServerClientThread. It reads from the socket connection specified by ClientSocket using a thread-local instance of TWinSocketStream.procedure TMyServerThread.ClientExecute;var
      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;