Example showing flatbuffer use over network (c++)?

3,808 views
Skip to first unread message

Shahbaz Chaudhary

unread,
Sep 8, 2015, 1:36:54 PM9/8/15
to FlatBuffers
As I mentioned in my earlier message, I have written a set of definitions for a number of messages and now I'm trying to do an end-to-end test. I'm not clear on how framing works for flatbuffers messages. If I'm reading messages off the wire, am I responsible for getting the right sized chunks of bytes and feeding them to flatbuffers infrastructure or can fb take a look at the first X bytes and figure out the message format?

This and several other questions could be best answered with a more complete example (I'm also relatively new to c++ so that might be tripping me up as well). I don't see any blog posts or 3rd party tutorials, but please let me know if i missed something.


Stewart Miles

unread,
Sep 8, 2015, 1:45:24 PM9/8/15
to Shahbaz Chaudhary, FlatBuffers
If you're feeling ambitious (may be a bit much since you're new to C++) you could take a look at the multiplayer support in Pie Noon which uses flatbuffers to communicate between each client (controller) and the server application.


https://github.com/google/pienoon/blob/master/src/gpg_multiplayer.cpp SendMessage() and GetNextMessage() contain the send / receive code.

Cheers,
Stewart

On Tue, Sep 8, 2015 at 10:36 AM, Shahbaz Chaudhary <shah...@gmail.com> wrote:
As I mentioned in my earlier message, I have written a set of definitions for a number of messages and now I'm trying to do an end-to-end test. I'm not clear on how framing works for flatbuffers messages. If I'm reading messages off the wire, am I responsible for getting the right sized chunks of bytes and feeding them to flatbuffers infrastructure or can fb take a look at the first X bytes and figure out the message format?

This and several other questions could be best answered with a more complete example (I'm also relatively new to c++ so that might be tripping me up as well). I don't see any blog posts or 3rd party tutorials, but please let me know if i missed something.


--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shahbaz Chaudhary

unread,
Sep 8, 2015, 2:43:10 PM9/8/15
to FlatBuffers, shah...@gmail.com
Thanks Stewart,
Am I correct in thinking that messages framing is handled outside of the flatbuffer framework? For instance, MessageReceivedCallback seems to contain a single message received off the wire. However, can fb be used to read raw bytes and have _it_ figure out where one message finishes and the other starts?

Stewart Miles

unread,
Sep 8, 2015, 6:59:26 PM9/8/15
to Shahbaz Chaudhary, FlatBuffers
Yeah the data ends up being framed in a TCP/IP packet which encodes the size of the payload.  We're only sending one flatbuffer in each message, if you want to send more message types you could consider using a union.
Reply all
Reply to author
Forward
0 new messages