-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
建议:TcpPullServer增加一个"查找byte序列"的HP_TcpPullServer_Find()方法 #45
Comments
gmxyb
changed the title
建议:TcpPullServer增加一个"指定分隔字符串"的Fetch()方法
建议:TcpPullServer增加一个"查找byte序列"的HP_TcpPullServer_Find()方法
Aug 14, 2018
可能你使用pull的方式有问题,正常情况下只要你的应用层协议定义得合理(包头包体清晰)是不需要调用HP_TcpPullServer_Peek方法的。可参考相关示例DEMO。 |
谢谢回答。我遇到的是别人定的不定长协议。。 |
不定长也可以用PULL,只要包头能拿到包体的长度 |
大哥,就是因为包头也不定长,不然我也不会提这个了。。 |
如果不同包类型的包头长度固定或包头的最前字节为包类型和包头长度还好处理,可以对包头进行二次解析。否则只能自己处理了,或者直接用PUSH模型。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
目前只能每次用 HP_TcpPullServer_Peek 先取出来自己在临时的buffer中查找分隔符,多了很多无效的内存拷贝。
建议提供一个可以直接在内部缓冲区查找特定BYTE序列的函数,这样就不需要全部Peek出来了。
int HP_TcpPullServer_Find(HP_TcpPullServer pServer, HP_CONNID dwConnID, BYTE* pFind, int iLength);
pFind是需要匹配的序列, iLength 是pFind 的字节数(必须>=1)
返回值:如果 >0 表示匹配到了,可以Fetch的字节数(包含末尾的pFind),如果 <=0 则未找到
The text was updated successfully, but these errors were encountered: