Designing a Simple Network Pack

I am learning socket programming (in python) and I was wondering what is the best / typical way to encapsulate data? My packages will be used to issue start, stop, configure, etc. On the receiving side. Is it useful to use JSON or just plain text?

+3
source share
4 answers

I suggest you use a fixed or mostly fixed format, as this simplifies the process.
By then, using functions like the standard struct.Struct library , with its pack () and umpack () methods, or perhaps some of the more recognized pacakges like Construct , you should have done most of the parsing work, -)

+1
source

I suggest a simple text to start with - it’s easier to debug. The format that your text takes depends on what you are doing, the number of commands, arguments, etc. Have you decided what your teams will look like? As soon as you figure out what it looks like, most likely it will offer the format on its own.

TCP UDP? TCP , , UDP, UDP , , .

+1

- , , ( ).

, / .

, , , (, wirehark) telnet .

, .

0

See how scapy (the awesome Python package management library) implements it. It looks like a few fields .

0
source

Source: https://habr.com/ru/post/1721235/


All Articles