关于as3 socket的粘包问题
可以查看,学习点思路
注意,每一次的读取ba.readBytes(temp,offest,length);方法,真实的position=offest都是从当前的位置为起点+上一次的位置,length就是长度了
var ba:ByteArray=new ByteArray();
ba.writeUTFBytes("for test for tews for test for tewsfor test for tews");
// ba.writeUnsignedInt(15);
trace(ba.length);
ba.position=0;
for(var i:uint=0;ba.bytesAvailable;i++)
{
var temp:ByteArray=new ByteArray();
ba.readBytes(temp,2,4);
trace("\n",temp.readUnsignedInt(),"ba.postion",ba.position);
}
}
52
26223 ba.postion 4
29797 ba.postion 8
8294 ba.postion 12
8308 ba.postion 16
29472 ba.postion 20
29216 ba.postion 24
29556 ba.postion 28
28530 ba.postion 32
25975 ba.postion 36
28530 ba.postion 40
25971 ba.postion 44
26223 ba.postion 48
29797 ba.postion 52
http://bbs.9ria.com/viewthread.php?tid=46012&page=1
http://www.klstudio.com/post/177.html
posted on 2011-04-15 17:52 songqiuming 阅读(1321) 评论(0) 编辑 收藏 举报