W
wzwcn
Unregistered / Unconfirmed
GUEST, unregistred user!
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3188558
------------------------------------
我用INDY的IdUDPServer控件写个测试程序;
数据包:
type
DataPake=packed record
a,b:string[10];
Lab:Tlabel;
mylist:tstringlist;
end;
发送:
procedure TForm1.Button2Click(Sender: TObject);
var dataataPake;
lab:Tlabel;
begin
data.a:='aaaa';
data.b:='bbbb';
data.Lab:=Tlabel.Create(nil);
data.Lab.Caption:='ok';
data.Lab.Font.Color:=rgb(255,0,0);
data.Lab.Left:=50;
data.lab.Top:=50;
data.Lab.Font.Size:=50;
data.mylist:=Tstringlist.Create;
data.mylist.Add('dskfj');
data.mylist.Add('sdklfjls');
data.mylist.Add('dsflsdjfl');
client.Sendbuffer('127.0.0.1',2005,data,sizeof(data));
end;
接收:
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var dataataPake;
begin
Adata.Read(data,Adata.size);
label1.Caption:=data.a;
label2.Caption:=data.b;
data.Lab.Parent:=self;
memo1.Lines:=data.mylist;
end;
请问各位大侠我的代码错在哪里。或者如何实现;
谢谢
------------------------------------
我用INDY的IdUDPServer控件写个测试程序;
数据包:
type
DataPake=packed record
a,b:string[10];
Lab:Tlabel;
mylist:tstringlist;
end;
发送:
procedure TForm1.Button2Click(Sender: TObject);
var dataataPake;
lab:Tlabel;
begin
data.a:='aaaa';
data.b:='bbbb';
data.Lab:=Tlabel.Create(nil);
data.Lab.Caption:='ok';
data.Lab.Font.Color:=rgb(255,0,0);
data.Lab.Left:=50;
data.lab.Top:=50;
data.Lab.Font.Size:=50;
data.mylist:=Tstringlist.Create;
data.mylist.Add('dskfj');
data.mylist.Add('sdklfjls');
data.mylist.Add('dsflsdjfl');
client.Sendbuffer('127.0.0.1',2005,data,sizeof(data));
end;
接收:
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
ABinding: TIdSocketHandle);
var dataataPake;
begin
Adata.Read(data,Adata.size);
label1.Caption:=data.a;
label2.Caption:=data.b;
data.Lab.Parent:=self;
memo1.Lines:=data.mylist;
end;
请问各位大侠我的代码错在哪里。或者如何实现;
谢谢