gpt4 book ai didi

c# - Protocol Buffer - protobuf-csharp-port : Does the equivalent of JAVA API call CodedInputStream. getBytesUntilLimit() 存在吗?

转载 作者:太空宇宙 更新时间:2023-11-03 13:34:19 25 4
gpt4 key购买 nike

我正在通过 Windows 命名管道将( Protocol Buffer )序列化消息从 Java 应用程序发送到 .net C# 应用程序。

我已经为这两种环境编译了一个 .proto 文件。在 C# 端,我使用 protobuf-csharp-port。

我计划在流中使用长度前缀包。

在c#端读取messageLength后,我使用CodedInputStream.pushLimit(messageLength)。然后我想在这样的循环中使用 cis.getBytesUntilLimit() 检索实际消息:

  do
{
builder.mergeFrom(cis);
} while (cis.getBytesUntilLimit() > 0);

但不幸的是,我在 protobuf-csharp-port 中找不到方法 getBytesUntilLimit()。

问题:protobuf-csharp-port中是否存在getBytesUntilLimit()? protobuf-csharp-port 是否忠实地在 .net 中实现了来自 Google 的所有 JAVA API(或至少是等效的)?

谢谢。

最佳答案

刚读了protobuf-csharp-port的源码,注意到一个属性ReachedLimit。我的问题的答案是:

do
{
builder.MergeFrom(cis);
} while (!cis.IsAtEnd);

关于c# - Protocol Buffer - protobuf-csharp-port : Does the equivalent of JAVA API call CodedInputStream. getBytesUntilLimit() 存在吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19183448/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com