Take the 2-minute tour ×  We are using JSON right now and want
to move to a binary format for some types of messages between
client and server.  Should I just read structs into the socket?
Use proticol buffers/thrift?  How should I represent arrays of
data?  What should the interface look like for packing/unpacking
data?  share|improve this question add comment  2 Answers     1.
you are talking about converting to a buffer of bytes   2. You
are using UDP and performance is a concern  Try to avoid wasting
space in your packet for defining structure. I.E. send, at
minimum, a byte to denote the type of packet, then just assume
each packet received follows the predefined structure for that
type of packet     • Yes, read the whole struct IF you NEED the
whole struct   • No, make the packet structure yourself, This
will surely be smaller than serialization using these methods;
you should know exactly what data the packet should include  How
should I represent arrays of data?    • As arrays of data. When
receiving c