I'm working on a C++ application that receives protocol buffers over a network socket. This seems like a core use case of Protobuf, but surprisingly most of the example C++ code I've found when googling about this has not been great. I've seen several examples of people reading from the socket into a fixed-size buffer, then passing that to an ArrayInputStream and finally a CodedInputStream. This seems less than ideal because it requires reading from the socket by hand and knowing in advance an upper limit on the size of the message. So I have been looking for an implementation of a ZeroCopyInputStream that can take a socket file descriptor and parse messages from that directly.
There is a FileInputStream class which can read directly from a file descriptor, but unfortunately it does not support sockets because it relies on the lseek system call. So I am thinking about doing the following to add an analogous class with support for sockets: 1. Create a CopyingSocketInputStream class that implements CopyingInputStream much like CopyingFileInputStream but without relying on lseek. 2. Wrap that in a CopyingInputStreamAdaptor to get a ZeroCopyInputStream implementation I was thinking of doing likewise to create a ZeroCopyOutputStream as well. Is this a reasonable approach or is there an easier way to do it that I am missing? Thanks! Best, Adam -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/groups/opt_out.