I'm developing a secure file transfer system with Python and I'm dealing now with the protocol. My idea is to have something like:
[Command:1byte][DataLength:2bytes][Data]
My problem is that I have no idea on how to deal with binary/hex in Python.
Imagine that I send a packet which command (in binary) is 00000001
(1byte). The dataLength = 200 bytes, then, since I have 16bits to store it, I have 0000000011001000
. So the header is: 000000010000000011001000
. The question is: how to send that "raw", without coding the 0's and 1's with 1byte each?