Beginner question: binary data and socket.send

Boris Epel boep777 at googlemail.com
Mon Dec 21 18:31:38 EST 2009


Hi! Please help with the problem:
send over TCPIP data packet organized as 6 bytes of identifier,
integer (LSB) and length of following binary data, binary data
the clear part:  create socket, connect it, use send, close socket
the unclear part:  create string with required data to use with send
what I tried:
buffer = [for i in range(23)];
buffer[0:5]="BBBBBB"
command = 0
buffer[6:9] = (command >> i & 255 for i in range(0,32,8))
datalength = 10
buffer[10:13] = (datalength >> i & 255 for i in range(0,32,8))
here i surrendered since buffer is a list of int and i need string ...
Suggestions are appreciated! boris



More information about the Python-list mailing list