I wondering why most of the protocols (Like dns for example) write the length of a string before it.
For example:
3www6google3com
Why did it do this in that way? I can't figure out through searches over the internet.
I wondering why most of the protocols (Like dns for example) write the length of a string before it.
For example:
3www6google3com
Why did it do this in that way? I can't figure out through searches over the internet.
Copyright © 2021 Jogjafile Inc.
Because that way we don't limit what can be in the string. The alternative is to use some sort of in-band signaling of the end of the string, like C's
\0, which either means you can't have some kinds of data in it, or that you have to deal with quoting of some sort. Prefix lengths are much easier to work with and less error-prone.