代码如下:
发送过程:
function SendOrder(SendBuf:TByteDynArray): Integer;
var
  Stream:TMemoryStream;
begin
  Result:=0;  //if send ok then return 0 else return non zero
  try
    try
      if fIdTCPClient.Connected then
      begin
        Stream:=TMemoryStream.Create;
        try
          Stream.Write(SendBuf[0],Length(SendBuf));
          fIdTCPClient.WriteStream(Stream,True,True);
        finally
          Stream.Free;
        end; 
      end
      else  //connect error,return error code 1
        Result:=1;
    except  //if send error then return 1
      Result:=1;
    end;
  finally
  end;
end;接收过程:
procedure TReceiveThread.Execute;
var
  ReceiveBuf:TByteDynArray;
  str:string;
  i:integer;
  count:integer;
  stream : TStream;
begin
  { Place thread code here }
  self.FreeOnTerminate:=True;
  while not (Terminated ) and fIdTCPClient.Connected  do
  begin
    count:=fIdTCPClient.ReadFromStack;
    if count<>0 then
    begin
      SetLength(ReceiveBuf,count);
      Stream:=TMemoryStream.Create;      fIdTcpClient.ReadStream(stream,count);//---接收到的数据为0。
      stream.Read(ReceiveBuf[0],count);//--读到的数据为0
      Str:='';
      for i:=0 to length(ReceiveBuf)-1 do
      begin
        str:=str+' '+ IntToHex(ReceiveBuf[i],2);
      end;
      fReceiveBuf :=str;
      stream.Free;
    end;
    sendmessage(fMessagedForm.Handle,WM_Data,self.ThreadID,0);
  end;end;
问题是:我单步跟踪发现
  fIdTcpClient.ReadStream(stream,count);//---接收到的数据为0。
  stream.Read(ReceiveBuf[0],count);//--读到的数据为0
全是0.请问这是为什么?