C++相当于 SerializeWithLengthPrefix

发布于 2024-08-05 03:58:22 字数 315 浏览 4 评论 0原文

我使用协议缓冲区 (protobuf-net) 使用套接字(TcpListener 和 TcpClient)构建了一个通信库,并且工作正常,但现在同事需要编写一个库来使用 C++ 与我的软件进行通信。

事实证明,我正在使用 Serializer.NonGeneric.SerializeWithLengthPrefixSerializer.NonGeneric.TryDeserializeWithLengthPrefix

protobuf C++ 库中是否有等效的函数?如果没有,有人知道如何实现它,或者已经实现分享吗?

I built a communication library using Protocol Buffers (protobuf-net) using Sockets (TcpListener and TcpClient) and it is working fine, but now a co-worker needs to write a library to communicate with my software using C++.

Turns out that I'm using the Serializer.NonGeneric.SerializeWithLengthPrefix and Serializer.NonGeneric.TryDeserializeWithLengthPrefix.

Are there equivalent functions in the protobuf C++ libraries? If not, anyone knows how to implement it, or have it implemented to share?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乙白 2024-08-12 03:58:22

我对 C++ API 不太熟悉;但如果您首先将数据写入缓冲区,那么长度前缀本身就非常简单,特别是如果您使用固定宽度 32 位编码(而不是 base-128 可变长度)。另请参阅 google-groups 论坛上的此帖子

I'm not hugely familiar with the C++ API; but the length prefix itself is pretty simple if you write the data to a buffer first, especially if you use the fixed-width 32-bit encoding (rather than base-128 variable-length). See also this thread on the google-groups forum.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文