I am using go
and protocol buffers
. go
program sends encoded protocol buffer messages to clients connected to the socket. Now since protocol-buffers is not delimited, clients don't know how much data to read from the socket.
I am planning to prefix the message with the message length, a 32bit integer. So clients can read 4 bytes, get the length and read the full message.
I can put an integer value into the bytes array using binary
package. Something like,
binary.Write(buf, binary.LittleEndian, value)
Now the question is, write
needs a byte order and how will the receiving end know what is the byte order? Is there a way to deal with this without specifying explicit byte order?