var sbuf :array[1..290] of Byte;
count:integer;
begin
count:=Socket.ReceiveBuf(sbuf,SizeOf(sbuf));
end;测试出来sbuf为(应该是十进制数组?)(2, 0, 1, 1, 26, 84, 6, 80, 68, 1, 71, 1, 0, 0, 43, 162, 0, 201, 14, 83, 8, 0, 0, 51, 18, 7, 27, 1, 11, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 82, 0, 0, 10, 201, 11, 1, 255, 255, 0, 0, 10, 201, 10, 250, 0, 1, 1, 3, 129, 219, 0, 0, 0, 0, 1, 24, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 103, 16, 0, 16, 6, 2, 86, 0, 82, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 255, 156, 0, 0, 1, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 115, 1, 132, 0, 0, 0, 0, 0, 0, 134, 32, 0, 15, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 250, 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 0, 0, 143, 251, 5, 255, 0, 0, 255, 128, 5, 16, 0, 0, 7, 12, 5, 29, 0, 0, 255, 254, 5, 0, 0, 0, 139, 144, 60, 15, 160, 0, 0, 0, 0, 35, 47, 35, 35, 35, 160, 0, 212, 255, 160, 0, 160, 0, 160, 0, 0, 60, 0, 0, 0, 0, 0, 0, 35, 35, 35, 35, 35, 160, 0, 159, 255, 160, 139, 150, 3)怎么把这些读取出来。
Move(sbuf[0],i,SizeOf(Integer));
我要转换成string
如果你的是一连串的数据的话,使用string转为后,遇到byte数组值是 0 的地方,字符串就结束了。
如果是一个结构体的话,应该耽搁元素处理,不会出现数据丢失问题。
可以直接强制转换string(sbuf)
var sbuf :array[1..290] of Byte;
count:integer;
tmps:string;
begin
count:=Socket.ReceiveBuf(sbuf,SizeOf(sbuf));
SetLength(tmps,count);
MoveMemory(@tmps[1],@array[0],count);
end;
i,count:integer;
tmps:string;
begin
count:=Socket.ReceiveBuf(sbuf,SizeOf(sbuf));
for i := 0 to count -1
begin
tmps := tmps + ord(sbuf[i]) + ',';
end;
end;
i,count:integer;
tmps:string;
begin
count:=Socket.ReceiveBuf(sbuf,SizeOf(sbuf));
for i := 0 to count -1 do
begin
tmps := tmps + ord(sbuf[i]) + ',';
end;
end;