On 15 Nov 2013, at 23:09,
se...@sean-bollin.com wrote:
> What is a typical way of breaking up what you receive into distinct sends?
Size fields or delimiters (or both, but that is not actually necessary).
http://stackoverflow.com/questions/1046637/writing-a-stream-protocol-message-size-field-or-message-delimiter
http://en.wikipedia.org/wiki/Delimiter
"Delimiter - Wikipedia, the free encyclopedia”
> You need to implement a message protocol of sorts? Like, end each send with "\n" ? And then on the server side splitting the data you received by the "\n" character?
If newlines can’t occur in your messages, that’s fine.
Otherwise, see above. The delimiter scheme that gives data transparency as well as good efficiency is COBS:
http://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing
Or start every message with its length (and then there is chunking, if you don’t know the length when starting to encode the message; HTTP has an ugly version of that).
http://en.wikipedia.org/wiki/Chunked_transfer_encoding
Often, you are best off using a self-delimiting message format such as XML, JSON or CBOR.
Grüße, Carsten