zinx icon indicating copy to clipboard operation
zinx copied to clipboard

字节序问题

Open mdyshad0w opened this issue 6 years ago • 2 comments
trafficstars

pack:binary.Write(dataBuff, binary.LittleEndian, msg.GetMsgId()) unpack:binary.Read(dataBuff, binary.LittleEndian, &msg.DataLen) 这种方式的话,客户端是不是需要对应也要用小端字节序处理,go里没有本地字节序和网络字节序相互转换的方法吗?这个难道就这样处理吗?不太懂,求大佬解释一下...

mdyshad0w avatar Oct 21 '19 07:10 mdyshad0w

这里实际上是默认了客户端是 LittleEndian小端方式。 如果客户端的发包应用数据是通过大端打包,那么这里就应该改成对应的大端模式就可以了。

aceld avatar Oct 22 '19 10:10 aceld

搭个车... 想邀请Repo参与者来w3c.group创建项目的对应小组。w3c.group是类似知识星球的社群工具,小组可设置为付费且有赞助功能,同时也是一个区块链主导的创作者社区。这是相关介绍: http://t.cn/Ai1vLcCU http://t.cn/Ai1vLcCG http://t.cn/Ai1vLcCA

isdotjim avatar Oct 24 '19 04:10 isdotjim

现在增加了拦截器Interceptor的能力,支持用户自定义大小端的模式了。

aceld avatar Apr 06 '23 01:04 aceld