For new comer of network programming, there is a big obfuscation, "how to make my own protocol to encode package sends to peer network application?". Fortunately, pioneers of network programming leaves us a classical pattern, TLV(Type-Length-Value). Type and Length is fix size array, for instance, Type is 2 bytes, Length is 2 or 4 bytes. Length is the length of following value.
对于很多网络编程的新手来说,如何设计自己的通信协议是一个比较迷惑的问题。但是,前人给我们遗留下来了一个好的模式,(类型-长度-值)模式。类型和长度都是固定长度的字段,比如,类型一般是2个字节,长度一般是2个或者4个字节。长度指明了接下来包里面的值的长度。
对于很多网络编程的新手来说,如何设计自己的通信协议是一个比较迷惑的问题。但是,前人给我们遗留下来了一个好的模式,(类型-长度-值)模式。类型和长度都是固定长度的字段,比如,类型一般是2个字节,长度一般是2个或者4个字节。长度指明了接下来包里面的值的长度。