When data is transferred through a network it is obviously in binary form.
So it could be a number
1011001
and then some other data, maybe
1110100111001
That are sent together.
How can we tell them apart when they arrive. Is there some special flag that indicates the end of each data?
If yes how do we make sure that it is unique and we don't get confused?
You could define a special bitstring pattern as the beginning or end of a stream and some protocols do this, but you would have to make it either long enough (256-bit for example) that it is highly unlikely that it appears in the normal data stream.
A more reliable way would be to escape the ending pattern if it appears in the normal data. You probably know how that works, because everybody came into contact of using \ in strings at some point in time. They have to be escaped as \\.
A third way is applicable if you know in advance how long your stream will be, so you can send a length before actually sending the data.
The actual details are defined as the protocol and both sides must follow the structure of the protocol however it was defined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With