L
lhcming
Unregistered / Unconfirmed
GUEST, unregistred user!
....
type
//包头
THead = record
ID: Integer;
end;
//请求方
TAckFileInfo = record //文件信息
FileSize: Integer;
FileName: array [0..1024] of char;
end;
TAckData = record
pieceBuf: array [0..1024] of Char; //文件块。
Length: Word; //长度
end;
TAckBag = packed Record
Head: THead;
AckFileInfo: TAckFileInfo;
AckData: TAckData;
end;
pAckBag = ^TAckBag;
//回复方
TReqType = record
ID: Integer; //0:传输 1:取消 2: 完成
end;
TReqData = record //包体部分
Length: Word;
StartPos: Integer;
end;
TReqBag = packed record //整包.
Head: THead;
ReqType: TReqType;
ReqData: TReqData;
end;
pReqBag = ^TReqBag;
form1 = class(form)
.....
在接收收据的过程中出现错误.
//TBytes = array of Byte;
procedure TForm1.UdpServerUDPRead(Sender: TObject; AData: TBytes;
ABinding: TIdSocketHandle);
var
ReqBag: pReqBag;
AckBag: PAckBag;
Buf: TBytes;
MsgFrm: TMsgFrm;
begin
New(AckBag);
New(ReqBag);
CopyMemory(@AckBag,@AData,SizeOf(AData));
Dispose(Ackbag); //在这儿报错。
.....
我新建立一个new(Ackbag)
将收到的数据保存到Ackbag结构里,
然后释放.
但为什么释放的时候会报错呢?是不是在执行copymemory的方法的时候,改变了原来的地址呢?如果是的,哪我怎么保存接收到传进来的数据到结构中啊?
type
//包头
THead = record
ID: Integer;
end;
//请求方
TAckFileInfo = record //文件信息
FileSize: Integer;
FileName: array [0..1024] of char;
end;
TAckData = record
pieceBuf: array [0..1024] of Char; //文件块。
Length: Word; //长度
end;
TAckBag = packed Record
Head: THead;
AckFileInfo: TAckFileInfo;
AckData: TAckData;
end;
pAckBag = ^TAckBag;
//回复方
TReqType = record
ID: Integer; //0:传输 1:取消 2: 完成
end;
TReqData = record //包体部分
Length: Word;
StartPos: Integer;
end;
TReqBag = packed record //整包.
Head: THead;
ReqType: TReqType;
ReqData: TReqData;
end;
pReqBag = ^TReqBag;
form1 = class(form)
.....
在接收收据的过程中出现错误.
//TBytes = array of Byte;
procedure TForm1.UdpServerUDPRead(Sender: TObject; AData: TBytes;
ABinding: TIdSocketHandle);
var
ReqBag: pReqBag;
AckBag: PAckBag;
Buf: TBytes;
MsgFrm: TMsgFrm;
begin
New(AckBag);
New(ReqBag);
CopyMemory(@AckBag,@AData,SizeOf(AData));
Dispose(Ackbag); //在这儿报错。
.....
我新建立一个new(Ackbag)
将收到的数据保存到Ackbag结构里,
然后释放.
但为什么释放的时候会报错呢?是不是在执行copymemory的方法的时候,改变了原来的地址呢?如果是的,哪我怎么保存接收到传进来的数据到结构中啊?