On Sun, Jul 27, 2008 at 7:01 PM, Larry Bates <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: >> i want to send unsigned 32 bit integer to socket, and looking for >> something equivalent to this method... >> http://livedocs.adobe.com/flex/2/langref/flash/net/Socket.html#writeUnsignedInt() >> >> is there such method / library available in python?! > You will need to use struct module to build the 4 byte value and then send > it. > > Something like (not tested): > > import struct > us32bit = struct.pack("I", value) > s.send(us32bit)
thanks a lot!!! just to make sure if I want 32 bit or 4 bytes then should I use the short or integer or long? this is short >>> struct.pack('!h',3) '\x00\x03' this is integer >>> struct.pack('!i',3) '\x00\x00\x00\x03' this is long >>> struct.pack('!l',3) '\x00\x00\x00\x03' -- http://mail.python.org/mailman/listinfo/python-list