Thanks, I got something working...how does this look? (ugly
I'm sure...)
On the C++ server side I am looping sending many messages
(all of the same type), and on the Java side I am looping parsing them
out.
C++ Server:
int size =
message.ByteSize();
EnsureBufferIsAtLeastSize(size
+ 4);
char* pBuffer = (char*)
google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(size,
(google::protobuf::uint8*)
m_pBuffer);
// Serialize the
message
bool result =
message.SerializeToArray(pBuffer, size);
// Calculate how many bytes
the 'size' took
int sizeSize = pBuffer -
m_pBuffer;
// Write the message to the
stream
m_Stream.Write(m_pBuffer,size +
sizeSize);
Java client:
com.google.protobuf.CodedInputStream
stream = com.google.protobuf.CodedInputStream.newInstance(url.openStream());
while ( !stream.isAtEnd()
)
{
Foor.Bar.Builder
builder =
Foo.Bar.newBuilder();
stream.readMessage(builder,
null);
Foo.Bar message
=
builder.build();
}
From: Christopher Smith
[mailto:cbs...@gmail.com]
Sent: Monday, June 15, 2009 2:58
PM
To: Alex Black
Cc: Protocol Buffers
Subject:
Re: 'Streaming' messages (say over a socket)