C
chimney
Unregistered / Unconfirmed
GUEST, unregistred user!
在每个数据包后添加结束符(回车/#13)
数据包结构:
TPacket=Record
A:Integer;
B:Integer;
C:Integer;
Data:array[0..4096-3*SizeOf(integer)-1] of Char
end
var
Packet:TPacket;
SendSize:integer;
SendBuf:array[0..4095] of Char;
begin
With Packet do
begin
A:=10;
B:=13;
C:=10;
Data:='ABCDEF'+#13;
end;
SendSize:=SizeOf(Integer)*3+7;
Move(Packet,SendBuf,SendSize);
.
.
.
.
end;
SendBuf内容变成了:#10#13#10'A''B''C''D''E''F'#13.....
接收端根据#13的位置判断数据包是否结束就出错了,怎么办?
数据包结构:
TPacket=Record
A:Integer;
B:Integer;
C:Integer;
Data:array[0..4096-3*SizeOf(integer)-1] of Char
end
var
Packet:TPacket;
SendSize:integer;
SendBuf:array[0..4095] of Char;
begin
With Packet do
begin
A:=10;
B:=13;
C:=10;
Data:='ABCDEF'+#13;
end;
SendSize:=SizeOf(Integer)*3+7;
Move(Packet,SendBuf,SendSize);
.
.
.
.
end;
SendBuf内容变成了:#10#13#10'A''B''C''D''E''F'#13.....
接收端根据#13的位置判断数据包是否结束就出错了,怎么办?