简体   繁体   English

协议缓冲区-protobuf-csharp-port:是否存在等效的JAVA API调用CodedInputStream.getBytesUntilLimit()?

[英]Protocol Buffers - protobuf-csharp-port : Does the equivalent of JAVA API call CodedInputStream.getBytesUntilLimit() exist?

I am sending (protocol buffer) serialized messages from a java application to a .net c# application over a Windows named pipe. 我正在通过Windows命名管道从Java应用程序向.net c#应用程序发送(协议缓冲区)序列化消息。

I have compiled a .proto file for both environments. 我已经为两种环境编译了一个.proto文件。 On the c# side, I use protobuf-csharp-port. 在C#端,我使用protobuf-csharp-port。

I was planning to use length-prefixed packages over the stream. 我打算在流中使用带有长度前缀的包。

After reading the messageLength on the c# side, I use CodedInputStream.pushLimit(messageLength). 在c#端阅读messageLength之后,我使用CodedInputStream.pushLimit(messageLength)。 I then wanted to retrieve the actual message using cis.getBytesUntilLimit() in a loop like this: 然后,我想使用cis.getBytesUntilLimit()在这样的循环中检索实际消息:

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

But unfortunately I could not find the method getBytesUntilLimit() in protobuf-csharp-port. 但不幸的是,我在protobuf-csharp-port中找不到方法getBytesUntilLimit()。

Question: Does getBytesUntilLimit() exist in protobuf-csharp-port? 问题:protobuf-csharp-port中是否存在getBytesUntilLimit()? Does protobuf-csharp-port faithfully implement in .net all the JAVA API from Google (or at least the equivalent thereof)? protobuf-csharp-port是否在.net中忠实地实现了Google的所有JAVA API(或至少等效的实现)?

Thank you. 谢谢。

Just read the source code of protobuf-csharp-port and noticed a property ReachedLimit. 只需阅读protobuf-csharp-port的源代码,就会注意到一个属性ReachedLimit。 The answer to my question is: 我的问题的答案是:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 protobuf的-CSHARP端口 - protobuf-csharp-port protobuf-csharp-port是否支持Windows RT? - Does protobuf-csharp-port support Windows RT? protobuf-csharp-port 和 protobuf-net 如何选择 - How to choose between protobuf-csharp-port and protobuf-net 如何在 Windows 下在 Mono 上构建 protobuf-csharp-port - How to build protobuf-csharp-port on Mono under Windows 是否可以在protobuf-csharp-port中检测消息类型? - Is it possible to detect message type in protobuf-csharp-port? 使用带有protobuf-csharp-port的文件记录和重播人类可读的protobuf消息 - Record and replay human-readable protobuf messages using a file with protobuf-csharp-port 有没有办法将protobuf-csharp-port生成的类与servicestack.ormlite一起使用? - Is there way to use protobuf-csharp-port generated classes with servicestack.ormlite? protobuf-csharp-port这些工具最适合今天使用什么版本? - protobuf-csharp-port what version(s) of these tools are best to use today? protobuf-csharp-port-来自文件的流记录有点像LINQ-to-XML中的轴函数 - protobuf-csharp-port - streaming records from a file a bit like an axis function in LINQ-to-XML ReadRawVarint32()的问题-Google协议缓冲区csharp-port - Problems with ReadRawVarint32() - Google Protocol Buffers csharp-port
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM