write unsigned integer 32 bits to socket
Larry Bates
larry.bates at websafe.com`
Sun Jul 27 22:01:05 EDT 2008
rkmr.em at gmail.com wrote:
> hi
> 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?!
>
>
> this is as far as i have gotten along
>>>> s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>>> s.connect(('127.0.0.1',3000))
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)
-Larry
More information about the Python-list
mailing list