From 2e6dc12fa8e8cf58a8ab27838b11f929b5cf909b Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Fri, 29 May 2009 06:34:52 +0100 Subject: Write/Read delimited messages --- src/ProtocolBuffers/IMessage.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/ProtocolBuffers/IMessage.cs') diff --git a/src/ProtocolBuffers/IMessage.cs b/src/ProtocolBuffers/IMessage.cs index e87bb52c..98b18a35 100644 --- a/src/ProtocolBuffers/IMessage.cs +++ b/src/ProtocolBuffers/IMessage.cs @@ -113,9 +113,26 @@ namespace Google.ProtocolBuffers { /// Serializes the message and writes it to the given output stream. /// This does not flush or close the stream. /// - /// + /// + /// Protocol Buffers are not self-delimiting. Therefore, if you write + /// any more data to the stream after the message, you must somehow ensure + /// that the parser on the receiving end does not interpret this as being + /// part of the protocol message. One way of doing this is by writing the size + /// of the message before the data, then making sure you limit the input to + /// that size when receiving the data. Alternatively, use WriteDelimitedTo(Stream). + /// void WriteTo(CodedOutputStream output); + /// + /// Like WriteTo(Stream) but writes the size of the message as a varint before + /// writing the data. This allows more data to be written to the stream after the + /// message without the need to delimit the message data yourself. Use + /// IBuilder.MergeDelimitedFrom(Stream) or the static method + /// YourMessageType.ParseDelimitedFrom(Stream) to parse messages written by this method. + /// + /// + void WriteDelimitedTo(Stream output); + /// /// Returns the number of bytes required to encode this message. /// The result is only computed on the first call and memoized after that. -- cgit v1.2.3