Usually the bytearray class will be your friend (if I understood your question correctly). You can send it through a socket:
my_bytes = bytearray() my_bytes.append(123) my_bytes.append(125) // my_bytes is b'{}' now s.send(my_bytes)
Follow the protocol specification and create a byte after the byte. This also works when you get data:
data = s.recv(2048) my_bytes = bytearray(data)
I know little about the SPDY protocol, but, for example, the control bit is the first bit (not byte) in the message. You can get it from my_bytes via the AND binary, for example:
control_frame = my_bytes[0] & 128
this is because 128 is 10000000 in binary format and therefore binary And will give you only the first bit (remember that each byte has 8 bits, so we have 7 zeros).
How everything is done manually. Of course, I suggest using some library, because writing a proper protocol handler will take a lot of time, it may seem to you that it is rather complicated and can be inefficient (depending on your needs, of course).
source share