Newbie: implementing lowlevel protocol over socket int32 data handling
Rob Renaud
rpgnmets at aol.com
Thu Jul 31 14:08:35 EDT 2003
Bram <b.neijt at ai.rug.nl> wrote in message news:<bgbaj5$kgv$2 at news4.tilbu1.nb.home.nl>...
> Hi,
> Summ: "What is the best way to handle int8,16 and 32 data in python?"
>
> Im currently working on a class to implement the gui protocol of
> mldonkey. (http://mldonkey.lemmster.de/wiki/index.php/GuiProtocol)
> However this requires to send int32 and int16 and even int8 integers.
>
> To create data I'm using the work-around of converting everything to hex
> values, and then converting the hex values to a data string wich I put
> on the socket (e.g. "\x00\xF0").
> I could do the same on the recieving end: chop it up in bytes and
> convert them to numbers (combining the hi and lo bytes of the int16 with
> some calculations)
>
> However, there must be a better way of doing this.
> Can anyone help me on this problem?
>
> Bram
This should make it a lot easier for you.
http://www.python.org/doc/current/lib/module-struct.html
But this will probably be the 4th post containing such a reference.
As undoubtedly 3 other people have posted it, but have not yet shown
up on google groups.
More information about the Python-list
mailing list