Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Beginner question: binary data and socket.send

Reply
Thread Tools

Beginner question: binary data and socket.send

 
 
Boris Epel
Guest
Posts: n/a
 
      12-21-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,)
datalength = 10
buffer[10:13] = (datalength >> i & 255 for i in range(0,32,)
here i surrendered since buffer is a list of int and i need string ...
Suggestions are appreciated! boris
 
Reply With Quote
 
 
 
 
Stephen Hansen
Guest
Posts: n/a
 
      12-21-2009
On Mon, Dec 21, 2009 at 3:31 PM, Boris Epel <> wrote:
> 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:


You probably want to take a look at the "struct" module to pack your
byte-strings with binary data.

HTH,

--S
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginner's Beginner william nelson Ruby 7 04-11-2011 11:23 PM
beginner help with sequential and binary search Ray Leon Java 25 07-12-2008 11:31 PM
beginner question about storing binary data in buffers, seeing binarydata in a variable, etc darren C++ 2 07-05-2008 01:58 PM
No Class at ALL!!! beginner/beginner question =?Utf-8?B?S3VydCBTY2hyb2VkZXI=?= ASP .Net 7 02-03-2005 02:47 PM
Tutorial for beginner/ Tutorial voor beginner Rensjuh C++ 7 09-02-2004 12:41 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57