smallnest / goframe Goto Github PK
View Code? Open in Web Editor NEWsend/receive framed data via TCP or QUIC
License: Apache License 2.0
send/receive framed data via TCP or QUIC
License: Apache License 2.0
我把example中的例子改成下面这样为啥就跑不通了呢?希望鸟哥解惑下
encoderConfig := goframe.EncoderConfig{
ByteOrder: binary.BigEndian,
LengthFieldLength: 2,
LengthAdjustment: -2,
LengthIncludesLengthFieldLength: false,
}
decoderConfig := goframe.DecoderConfig{
ByteOrder: binary.BigEndian,
LengthFieldOffset: 0,
LengthFieldLength: 2,
LengthAdjustment: -2,
InitialBytesToStrip: 0,
}
lengthFieldBasedFrameConn里的编码配置,我看了只有1,2,3,4,8, 能不能加上一个0,
我发现我现在的消息满足
3 bytes length field at the beginning of 5 bytes header, do not strip header
这个格式,但是不知道要用哪一个编解码器
希望可以得到解答
大佬,能打一个 tag 然后发布一个 release 吗?这样对 go.mod 包管理也规范一些,谢谢!
[]byte{ 0xFF,0xFF, //固定头1
0x09,//长度 = 序列号域 + 命令代码 + 数据域 +校验和域 (不包含 固定头1 固定头2)
0x80,//固定头2
0x31,//序列号域
0x32,//命令代码
0x33,0x34,0x35,0x36,0x37,0x38,//数据域
0xFA,//校验和域
}
使用
decoderConfig := goframe.DecoderConfig{
ByteOrder: binary.BigEndian,
LengthFieldOffset: 2, //起始域
LengthFieldLength: 1, //长度域
LengthAdjustment: 0 , //版本
InitialBytesToStrip: 3, // 起始域 + 长度域
}
期望值
0x31,//序列号域
0x32,//命令代码
0x33,0x34,0x35,0x36,0x37,0x38,//数据域
0xFA,//校验和域
实际解析出来
---------------------------------------------
003132333435
---------------------------------------------
3738FAFFFF09003132333435363738FAFFFF09003132333435363738FAFFFF09003132333435363738FAFFFF09003132333435
---------------------------------------------
3738FAFFFF09003132333435363738FAFFFF09003132333435363738FAFFFF09003132333435363738FAFFFF09003132333435
---------------------------------------------
3738FAFFFF09003132333435363738FAFFFF09003132333435363738FAFFFF09003132333435363738FA333435363738FAFFFF
---------------------------------------------
003132333435
---------------------------------------------
3738FAFFFF09003132333435363738FAFFFF09003132333435363738FAFFFF09003132333435363738FAFFFF09003132333435
---------------------------------------------
3738FAFFFF09003132333435363738FAFFFF09003132333435363738FAFFFF09003132333435363738FAFFFF09003132333435
请问该如何配置 ,谢谢您!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.