TServerSocket的多线程 长连接下面的程序能实现吗? 
我现在做的程序,会不停收到客户段重新连接上来的信息, 
然后又重复发送数据给客户端,内存消耗会不断的加大,怎么解决这个问题 
我的客户端数量最多80个,一般30个。 
下面我贴出代码 
  inherited FreeOnTerminate := True; 
  CoInitialize(nil); 
  Query1 := TAdoquery.Create(nil); 
  Query2 := TAdoquery.Create(nil); 
  Query1.Connection := Form1.ADOConnection1; 
  Query2.Connection := Form1.ADOConnection1; 
  while not Terminated and ClientSocket.Connected do 
  try 
    SocketStream := TWinSocketStream.Create(ClientSocket, 60000); 
    try 
      FillChar(struPrisoner, SizeOf(TPrisoner), 0); 
      if SocketStream.Read(struPrisoner, SizeOf(TPrisoner)) = 0 then 
      begin 
        // If we didn't get any data after 60 seconds then close the connection 
        ClientSocket.Close; 
        Terminate; 
      end; 
      if ClientSocket.Connected then begin //正常的处理 
        sleep(1); 
        b := false; 
      //**************************** protocol ******************************************// 
        StrCopy(@ArrRoom, @struPrisoner.szRoom); 
        szPrison := ArrRoom; 
        if struPrisoner.iCommand = 7 then 
        begin 
            //查询数据库内容发送给客户端 
            Query1.Next; 
          end; 
          icommand := 17; 
          ClientSocket.SendBuf(icommand, SizeOf(integer));         end;         if struPrisoner.iCommand = 14 then 
        begin 
          //查询数据库内容发送给客户端 
          ClientSocket.SendBuf(struPrisonInfo, sizeof(TPrisonInfo)); 
        end; 
                                {此处处理协议部分} 
      //**************************** protocol ******************************************// 
        if b = true then begin //接受close命令后 b=true 
          sleep(1); 
          ClientSocket.Close; 
          Terminate; 
        end; 
      end; 
    finally 
      SocketStream.Free; 
    end; 
  except 
    //HandleException; 
    ClientSocket.Close; 
    Query1.Free; 
    Query2.Free; 
    Terminate; 
  end; 
  CoUninitialize;