I'm trying to retrieve binary data using AS3 from a PHP server via HTTP, but very often (~50%) a few bytes arrive corrupted.
我正在尝试通过HTTP从PHP服务器使用AS3检索二进制数据,但是经常(~50%)几个字节到达时已损坏。
PHP snippets:
header('Content-Type:binary/octet-stream;');
echo $this->page;
AS3 snippet:
var resp:int=data.readByte();
var user_id:uint=data.readUnsignedInt();
var anon_id:uint=data.readUnsignedInt();
var token:ByteArray=new ByteArray();
data.readBytes(token,0,16);
Examples, with the sent data in the first line, and the received data in the second line (spaces added for readability):
示例,第一行中发送的数据,第二行中的接收数据(为便于阅读而添加的空格):
01000000110000000095cb4bca40fb d0bb ab7bdd15b3e973c7
01000000110000000095cb4bca40fb 3b ab7bdd15b3e973c7
010000001200000000bb5c4c55af caa9e9afd6 a7f550748b61
010000001200000000bb5c4c55af a9e9af a7f550748b61
010000001400000000e191ffbc222d239debe 8d69 0d93b7ca4
010000001400000000e191ffbc222d239debe 89 0d93b7ca4
0100000017000000002e1b75 db89 8a1a cd86 f05a8bf07c592b
0100000017000000002e1b75 c9 8a1a 46 f05a8bf07c592b
010000001a00000000b4d72a3a8cd b944 5d0559072d8d16583
010000001a00000000b4d72a3a8cd 44 5d0559072d8d16583
010000001e000000007 bc8a 377bd9feab432260d43db4a42ab
010000001e000000007 b2 377bd9feab432260d43db4a42ab
2 个解决方案
#1
-1
While I still have no idea what was happening, I dodged the problem transmitting hex encoded data in plain/text.
虽然我仍然不知道发生了什么,但我躲过了以普通/文本传输十六进制编码数据的问题。
#2
-1
There is not enough code shown. But, you may be suffering from inadvertent character encoding of binary data being treated as text.
没有显示足够的代码。但是,您可能会遭受被视为文本的二进制数据的无意字符编码。
#1
-1
While I still have no idea what was happening, I dodged the problem transmitting hex encoded data in plain/text.
虽然我仍然不知道发生了什么,但我躲过了以普通/文本传输十六进制编码数据的问题。
#2
-1
There is not enough code shown. But, you may be suffering from inadvertent character encoding of binary data being treated as text.
没有显示足够的代码。但是,您可能会遭受被视为文本的二进制数据的无意字符编码。