L
liuchong
Unregistered / Unconfirmed
GUEST, unregistred user!
发送端正常:
type
MyRec=record
Length:Word;
S:string;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
R,M:MyRec;
begin
R.S:=Edit1.Text;
R.Length:=Length(R.S);
idUDPServer1.SendBuffer('192.168.0.3',8001,R,SizeOf(R));
end;
//接收端出错:
type
MyRec=record
Length:Word;
S:string;
end;
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
R:MyRec;
begin
SetLength(R.S,AData.Size-3);
AData.ReadBuffer(R,AData.Size);
Caption:=R.S;//不能正常得到结果
end;
type
MyRec=record
Length:Word;
S:string;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
R,M:MyRec;
begin
R.S:=Edit1.Text;
R.Length:=Length(R.S);
idUDPServer1.SendBuffer('192.168.0.3',8001,R,SizeOf(R));
end;
//接收端出错:
type
MyRec=record
Length:Word;
S:string;
end;
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var
R:MyRec;
begin
SetLength(R.S,AData.Size-3);
AData.ReadBuffer(R,AData.Size);
Caption:=R.S;//不能正常得到结果
end;