本人使用TidTCPClient控件与TidTCPServer控件进行通讯,但是在使用流传输一定数量的数据。当数据量小于某一个大概的数值时(大约10万字节左右),能够正常工作,当数据量大于这个大概的值时,则服务器端返回处理结果出错。调试了很久也没有结果,请大侠们帮我看看,究竟是哪个地方不妥或者缺少了什么。万分感谢!客户端代码:
  IdTCPAppView.ReadTimeout:=3600000;
  IdTCPAppView.WriteLn('SetAcl3 '+ sDirectory);
  MS:=TMemoryStream.Create;
  pMem:=Pchar(sTrustee+'='+sPermission);
  MS.SetSize(StrLen(pMem));
  CopyMemory(MS.Memory,pMem,MS.Size);
  MS.Seek(0,soFromBeginning);
  IdTCPAppView.WriteStream(MS,true,true,MS.Size);
  MS.Free;
  try
    RetStr:= IdTCPAppView.ReadLn;
  except
    ON EIdConnClosedGracefully do begin Application.MessageBox(ssConnectionClosedGracefully,Pchar(Application.Title),MB_OK or MB_ICONSTOP);abort;end;
              ON EIdNotConnected do begin Application.MessageBox(Pchar(ssRSNotConnected),Pchar(Application.Title),MB_OK or MB_ICONSTOP);Abort;end;
              else SocketErrorReset;//处理其他通信错误
            end;服务器端代码:
procedure TfrmMain.AClSockSvrSetAcl3Command(ASender: TIdCommand);
var
  sDirectory,sTrustee,sPermission:string;
  bResult:boolean;
  RetParam:string;
  MS:TMemoryStream;
  pMem:Pchar;
begin
  if (Asender.Params.Count=0) then
     begin
       ASender.Thread.Connection.Writeln('');
       exit;
     end;
  sDirectory := ASender.Params[0];  MS:=TMemoryStream.Create;
  ASender.Thread.Connection.ReadStream(MS);
  MS.Seek(0,soFromBeginning);
  pMem:=AllocMem(MS.Size+1);
  CopyMemory(pMem,MS.Memory,MS.Size);
  MS.Seek(0,soFromBeginning);
  sTrustee:=copy(pMem,1,Ansipos('=',pMem)-1);
  sPermission:=copy(pMem,Ansipos('=',pMem)+1,length(pMem)-Ansipos('=',pMem));
  MS.Free;//此处本应该是处理客户端发过来的命令和数据,为排除干扰因素,将此部分代码注释了。  RetParam:='1';
  Application.MessageBox(Pchar('RetParam:'+RetParam),'',MB_OK);
  if  Asender.Thread.Connection.Connected  then begin
    ASender.Thread.Connection.Writeln(RetParam);//此处一执行,客户端马上抛出异常EidSocketError:Socket Error #10054 Connection reset by peer.
  end else Application.MessageBox(Pchar('Not Asender.Thread.Connection.Connected'),'',MB_OK);
      exit;为什么会有一个临界值的存在呢?当传输的数据量少于这个值,则一切工作正常,若大于,则将返回值RetParam写回去,客户端抛出异常?百思不得其解。