应该是你自己的问题吧.
看了一下你的代码:
//=======================================================================
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
car : DBCAR;
str:TMemoryStream;
begin
str:=TMemoryStream.Create;
str.LoadFromStream(AData);
str.Read(plan,str.Size);
Memo2.Lines.Add('类型:'+InttoStr(plan.Data_Type)+','
+'高:'+IntToStr(ntohl(plan.Height))+','
+'序号:'+IntToStr(plan.Call_Sign[0])+','
);
str.Free;
end;
//=========================================================
str.Read(plan,str.Size);==>这一句你改改看.改成str.Read(plan,sizeof(plan));
否则,你怎么确定sizeof(plan)=str.Size???????????????????????????????????????????????????????????????
假设你的sizeof(plan)=20,而str.Size=10,你又怎么可能指望后面的10字节正确????????
而且,你没必要再搞个什么额外的TMemorystream吧.
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
car : DBCAR;
begin
AData.Position:=0;
AData.Read(car,sizeof(car));
end;