How to collect the packets for transmission on the network? How best to encode?

How to collect packages? Yes, he just learning, so here is the question for the Assembly of such a byte sausages, some ready-made module or is it better to write your flexible encoder? If there are options not to invent a Bicycle it would be nice used the struct module, but was wondering how to then on the server or client to decode the sausage, he previously tried to write using utf8 varint and, after thinking if no good options to write completely his own, but again, I wonder how to collect the packets, ideally, to have painted what item and why, as I was advised:
The package ID
The weight of the package
Length of str
Long str

Language snake, he still learning and want detailed answers that as a Yes
0 answer

Find more questions by tags Data transmission protocolsSocketsCharacter encodingPython